Fix exceptions when signing out

This commit is contained in:
Alexander Zinchuk 2022-05-31 20:58:55 +04:00
parent e7781e10c9
commit 4cef87e2ab
2 changed files with 14 additions and 10 deletions

View File

@ -1,4 +1,5 @@
import { useEffect, useState } from '../lib/teact/teact';
import { useEffect } from '../lib/teact/teact';
import {
getOrderedIds,
getUnreadCounters,
@ -7,27 +8,28 @@ import {
addUnreadCountersCallback,
addChatsCountCallback,
} from '../util/folderManager';
import useForceUpdate from './useForceUpdate';
export function useFolderManagerForOrderedIds(folderId: number) {
const [orderedIds, setOrderedIds] = useState(getOrderedIds(folderId));
const forceUpdate = useForceUpdate();
useEffect(() => addOrderedIdsCallback(folderId, setOrderedIds), [folderId]);
useEffect(() => addOrderedIdsCallback(folderId, forceUpdate), [folderId, forceUpdate]);
return orderedIds;
return getOrderedIds(folderId);
}
export function useFolderManagerForUnreadCounters() {
const [unreadCounters, setUnreadCounters] = useState(getUnreadCounters());
const forceUpdate = useForceUpdate();
useEffect(() => addUnreadCountersCallback(setUnreadCounters), []);
useEffect(() => addUnreadCountersCallback(forceUpdate), [forceUpdate]);
return unreadCounters;
return getUnreadCounters();
}
export function useFolderManagerForChatsCount() {
const [chatsCount, setChatsCount] = useState(getChatsCount());
const forceUpdate = useForceUpdate();
useEffect(() => addChatsCountCallback(setChatsCount), []);
useEffect(() => addChatsCountCallback(forceUpdate), [forceUpdate]);
return chatsCount;
return getChatsCount();
}

View File

@ -46,6 +46,8 @@ const useInfiniteScroll = <ListId extends string | number>(
if (!viewportIdsRef.current || !areSortedArraysEqual(viewportIdsRef.current, newViewportIds)) {
viewportIdsRef.current = newViewportIds;
}
} else if (!listIds) {
viewportIdsRef.current = undefined;
}
const getMore: GetMore = useCallback(({