Change `<LoadGap>` to accept an arbitrary parameter

Renaud Chaput 2024-06-14 15:29:34 +02:00
parent 977415ca2e
commit 6d75bc6484
No known key found for this signature in database
GPG Key ID: BCFC859D49B46990
3 changed files with 8 additions and 8 deletions

View File

@ -9,18 +9,18 @@ const messages = defineMessages({
load_more: { id: 'status.load_more', defaultMessage: 'Load more' },
});
interface Props {
interface Props<T> {
disabled: boolean;
maxId: string;
onClick: (maxId: string) => void;
param: T;
onClick: (params: T) => void;
}
export const LoadGap: React.FC<Props> = ({ disabled, maxId, onClick }) => {
export const LoadGap = <T,>({ disabled, param, onClick }: Props<T>) => {
const intl = useIntl();
const handleClick = useCallback(() => {
onClick(maxId);
}, [maxId, onClick]);
onClick(param);
}, [param, onClick]);
return (
<button

View File

@ -106,7 +106,7 @@ export default class StatusList extends ImmutablePureComponent {
<LoadGap
key={'gap:' + statusIds.get(index + 1)}
disabled={isLoading}
maxId={index > 0 ? statusIds.get(index - 1) : null}
param={index > 0 ? statusIds.get(index - 1) : null}
onClick={onLoadMore}
/>
);

View File

@ -202,7 +202,7 @@ class Notifications extends PureComponent {
<LoadGap
key={'gap:' + notifications.getIn([index + 1, 'id'])}
disabled={isLoading}
maxId={index > 0 ? notifications.getIn([index - 1, 'id']) : null}
param={index > 0 ? notifications.getIn([index - 1, 'id']) : null}
onClick={this.handleLoadGap}
/>
) : (