mirror of
https://github.com/danog/telegram-tt.git
synced 2024-11-27 12:55:11 +01:00
Infinite Scroll: Fix missing chats
This commit is contained in:
parent
a6e2ca32fd
commit
911f80cae1
@ -11,7 +11,7 @@ import resetScroll from '../../util/resetScroll';
|
||||
type OwnProps = {
|
||||
ref?: RefObject<HTMLDivElement>;
|
||||
className?: string;
|
||||
onLoadMore?: ({ direction }: { direction: LoadMoreDirection }) => void;
|
||||
onLoadMore?: ({ direction }: { direction: LoadMoreDirection; noScroll?: boolean }) => void;
|
||||
onScroll?: (e: UIEvent<HTMLDivElement>) => void;
|
||||
onKeyDown?: (e: React.KeyboardEvent<any>) => void;
|
||||
items?: any[];
|
||||
@ -66,8 +66,12 @@ const InfiniteScroll: FC<OwnProps> = ({
|
||||
}
|
||||
|
||||
return [
|
||||
debounce(() => onLoadMore({ direction: LoadMoreDirection.Backwards }), 1000, true, false),
|
||||
debounce(() => onLoadMore({ direction: LoadMoreDirection.Forwards }), 1000, true, false),
|
||||
debounce((noScroll = false) => {
|
||||
onLoadMore({ direction: LoadMoreDirection.Backwards, noScroll });
|
||||
}, 1000, true, false),
|
||||
debounce(() => {
|
||||
onLoadMore({ direction: LoadMoreDirection.Forwards });
|
||||
}, 1000, true, false),
|
||||
];
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [onLoadMore, items]);
|
||||
@ -79,7 +83,7 @@ const InfiniteScroll: FC<OwnProps> = ({
|
||||
}
|
||||
|
||||
if (preloadBackwards > 0 && (!items || items.length < preloadBackwards)) {
|
||||
loadMoreBackwards();
|
||||
loadMoreBackwards(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,10 @@ export default (
|
||||
}
|
||||
}, [listIds, isDisabled, loadMoreBackwards, forceFullPreload]);
|
||||
|
||||
const getMore: GetMore = useCallback(({ direction }: { direction: LoadMoreDirection }) => {
|
||||
const getMore: GetMore = useCallback(({
|
||||
direction,
|
||||
noScroll,
|
||||
}: { direction: LoadMoreDirection; noScroll?: boolean }) => {
|
||||
const viewportIds = viewportIdsRef.current;
|
||||
|
||||
const offsetId = viewportIds
|
||||
@ -67,8 +70,6 @@ export default (
|
||||
return;
|
||||
}
|
||||
|
||||
lastParamsRef.current = { ...lastParamsRef.current, direction, offsetId };
|
||||
|
||||
const {
|
||||
newViewportIds, areSomeLocal, areAllLocal,
|
||||
} = getViewportSlice(listIds, offsetId, direction, listSlice);
|
||||
@ -79,6 +80,10 @@ export default (
|
||||
}
|
||||
|
||||
if (!areAllLocal && loadMoreBackwards) {
|
||||
if (!noScroll) {
|
||||
lastParamsRef.current = { ...lastParamsRef.current, direction, offsetId };
|
||||
}
|
||||
|
||||
loadMoreBackwards({ offsetId });
|
||||
}
|
||||
}, [listIds, listSlice, loadMoreBackwards, forceUpdate]);
|
||||
|
Loading…
Reference in New Issue
Block a user