Search: Fix infinite message loading (#2488)

This commit is contained in:
Alexander Zinchuk 2023-02-04 03:02:49 +01:00
parent 357eef783b
commit 422e13262f
6 changed files with 13 additions and 6 deletions

View File

@ -54,7 +54,8 @@ const AudioResults: FC<OwnProps & StateProps> = ({
}); });
}); });
} }
}, [currentType, lastSyncTime, searchMessagesGlobal]); // eslint-disable-next-line react-hooks/exhaustive-deps -- `searchQuery` is required to prevent infinite message loading
}, [currentType, lastSyncTime, searchMessagesGlobal, searchQuery]);
const foundMessages = useMemo(() => { const foundMessages = useMemo(() => {
if (!foundIds || !globalMessagesByChatId) { if (!foundIds || !globalMessagesByChatId) {

View File

@ -64,7 +64,8 @@ const ChatMessageResults: FC<OwnProps & StateProps> = ({
}); });
}); });
} }
}, [lastSyncTime, searchMessagesGlobal]); // eslint-disable-next-line react-hooks/exhaustive-deps -- `searchQuery` is required to prevent infinite message loading
}, [lastSyncTime, searchMessagesGlobal, searchQuery]);
const handleTopicClick = useCallback( const handleTopicClick = useCallback(
(id: number) => { (id: number) => {

View File

@ -16,6 +16,7 @@ import {
import { MEMO_EMPTY_ARRAY } from '../../../util/memo'; import { MEMO_EMPTY_ARRAY } from '../../../util/memo';
import { throttle } from '../../../util/schedulers'; import { throttle } from '../../../util/schedulers';
import { renderMessageSummary } from '../../common/helpers/renderMessageText'; import { renderMessageSummary } from '../../common/helpers/renderMessageText';
import useLang from '../../../hooks/useLang'; import useLang from '../../../hooks/useLang';
import useHorizontalScroll from '../../../hooks/useHorizontalScroll'; import useHorizontalScroll from '../../../hooks/useHorizontalScroll';
import useAppLayout from '../../../hooks/useAppLayout'; import useAppLayout from '../../../hooks/useAppLayout';
@ -85,7 +86,8 @@ const ChatResults: FC<OwnProps & StateProps> = ({
}); });
}); });
} }
}, [lastSyncTime, searchMessagesGlobal]); // eslint-disable-next-line react-hooks/exhaustive-deps -- `searchQuery` is required to prevent infinite message loading
}, [lastSyncTime, searchMessagesGlobal, searchQuery]);
const handleChatClick = useCallback( const handleChatClick = useCallback(
(id: string) => { (id: string) => {

View File

@ -66,7 +66,8 @@ const FileResults: FC<OwnProps & StateProps> = ({
}); });
}); });
} }
}, [lastSyncTime, searchMessagesGlobal]); // eslint-disable-next-line react-hooks/exhaustive-deps -- `searchQuery` is required to prevent infinite message loading
}, [lastSyncTime, searchMessagesGlobal, searchQuery]);
const foundMessages = useMemo(() => { const foundMessages = useMemo(() => {
if (!foundIds || !globalMessagesByChatId) { if (!foundIds || !globalMessagesByChatId) {

View File

@ -64,7 +64,8 @@ const LinkResults: FC<OwnProps & StateProps> = ({
}); });
}); });
} }
}, [lastSyncTime, searchMessagesGlobal]); // eslint-disable-next-line react-hooks/exhaustive-deps -- `searchQuery` is required to prevent infinite message loading
}, [lastSyncTime, searchMessagesGlobal, searchQuery]);
const foundMessages = useMemo(() => { const foundMessages = useMemo(() => {
if (!foundIds || !globalMessagesByChatId) { if (!foundIds || !globalMessagesByChatId) {

View File

@ -62,7 +62,8 @@ const MediaResults: FC<OwnProps & StateProps> = ({
}); });
}); });
} }
}, [lastSyncTime, searchMessagesGlobal]); // eslint-disable-next-line react-hooks/exhaustive-deps -- `searchQuery` is required to prevent infinite message loading
}, [lastSyncTime, searchMessagesGlobal, searchQuery]);
const foundMessages = useMemo(() => { const foundMessages = useMemo(() => {
if (!foundIds || !globalMessagesByChatId) { if (!foundIds || !globalMessagesByChatId) {