mirror of
https://github.com/danog/telegram-tt.git
synced 2024-11-27 04:45:08 +01:00
Fix exceptions when signing out
This commit is contained in:
parent
e7781e10c9
commit
4cef87e2ab
@ -1,4 +1,5 @@
|
|||||||
import { useEffect, useState } from '../lib/teact/teact';
|
import { useEffect } from '../lib/teact/teact';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getOrderedIds,
|
getOrderedIds,
|
||||||
getUnreadCounters,
|
getUnreadCounters,
|
||||||
@ -7,27 +8,28 @@ import {
|
|||||||
addUnreadCountersCallback,
|
addUnreadCountersCallback,
|
||||||
addChatsCountCallback,
|
addChatsCountCallback,
|
||||||
} from '../util/folderManager';
|
} from '../util/folderManager';
|
||||||
|
import useForceUpdate from './useForceUpdate';
|
||||||
|
|
||||||
export function useFolderManagerForOrderedIds(folderId: number) {
|
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() {
|
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() {
|
export function useFolderManagerForChatsCount() {
|
||||||
const [chatsCount, setChatsCount] = useState(getChatsCount());
|
const forceUpdate = useForceUpdate();
|
||||||
|
|
||||||
useEffect(() => addChatsCountCallback(setChatsCount), []);
|
useEffect(() => addChatsCountCallback(forceUpdate), [forceUpdate]);
|
||||||
|
|
||||||
return chatsCount;
|
return getChatsCount();
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,8 @@ const useInfiniteScroll = <ListId extends string | number>(
|
|||||||
if (!viewportIdsRef.current || !areSortedArraysEqual(viewportIdsRef.current, newViewportIds)) {
|
if (!viewportIdsRef.current || !areSortedArraysEqual(viewportIdsRef.current, newViewportIds)) {
|
||||||
viewportIdsRef.current = newViewportIds;
|
viewportIdsRef.current = newViewportIds;
|
||||||
}
|
}
|
||||||
|
} else if (!listIds) {
|
||||||
|
viewportIdsRef.current = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getMore: GetMore = useCallback(({
|
const getMore: GetMore = useCallback(({
|
||||||
|
Loading…
Reference in New Issue
Block a user