mirror of https://github.com/mastodon/mastodon.git
Change `<LoadGap>` to accept an arbitrary parameter
parent
977415ca2e
commit
6d75bc6484
|
@ -9,18 +9,18 @@ const messages = defineMessages({
|
||||||
load_more: { id: 'status.load_more', defaultMessage: 'Load more' },
|
load_more: { id: 'status.load_more', defaultMessage: 'Load more' },
|
||||||
});
|
});
|
||||||
|
|
||||||
interface Props {
|
interface Props<T> {
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
maxId: string;
|
param: T;
|
||||||
onClick: (maxId: string) => void;
|
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 intl = useIntl();
|
||||||
|
|
||||||
const handleClick = useCallback(() => {
|
const handleClick = useCallback(() => {
|
||||||
onClick(maxId);
|
onClick(param);
|
||||||
}, [maxId, onClick]);
|
}, [param, onClick]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -106,7 +106,7 @@ export default class StatusList extends ImmutablePureComponent {
|
||||||
<LoadGap
|
<LoadGap
|
||||||
key={'gap:' + statusIds.get(index + 1)}
|
key={'gap:' + statusIds.get(index + 1)}
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
maxId={index > 0 ? statusIds.get(index - 1) : null}
|
param={index > 0 ? statusIds.get(index - 1) : null}
|
||||||
onClick={onLoadMore}
|
onClick={onLoadMore}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -202,7 +202,7 @@ class Notifications extends PureComponent {
|
||||||
<LoadGap
|
<LoadGap
|
||||||
key={'gap:' + notifications.getIn([index + 1, 'id'])}
|
key={'gap:' + notifications.getIn([index + 1, 'id'])}
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
maxId={index > 0 ? notifications.getIn([index - 1, 'id']) : null}
|
param={index > 0 ? notifications.getIn([index - 1, 'id']) : null}
|
||||||
onClick={this.handleLoadGap}
|
onClick={this.handleLoadGap}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
|
Loading…
Reference in New Issue