From b80a1e0ee9a3705205ecfc3c486fddfb58e0f0dd Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 10 Dec 2021 18:33:00 +0100 Subject: [PATCH] [Refactoring] Get rid of redundant requests --- src/components/main/Main.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/components/main/Main.tsx b/src/components/main/Main.tsx index c72d8f180..37a922b62 100644 --- a/src/components/main/Main.tsx +++ b/src/components/main/Main.tsx @@ -128,31 +128,39 @@ const Main: FC = ({ loadNotificationSettings(); loadNotificationExceptions(); loadTopInlineBots(); - loadEmojiKeywords({ language: BASE_EMOJI_KEYWORD_LANG }); + } + }, [ + lastSyncTime, loadAnimatedEmojis, loadEmojiKeywords, loadNotificationExceptions, loadNotificationSettings, + loadTopInlineBots, updateIsOnline, + ]); + + // Language-based API calls + useEffect(() => { + if (lastSyncTime) { if (language !== BASE_EMOJI_KEYWORD_LANG) { loadEmojiKeywords({ language }); } loadCountryList({ langCode: language }); } - }, [ - lastSyncTime, loadAnimatedEmojis, loadNotificationExceptions, loadNotificationSettings, updateIsOnline, - loadTopInlineBots, loadEmojiKeywords, loadCountryList, language, - ]); + }, [language, lastSyncTime, loadCountryList, loadEmojiKeywords]); + // Check version when service chat is ready useEffect(() => { if (lastSyncTime && isServiceChatReady) { checkVersionNotification(); } }, [lastSyncTime, isServiceChatReady, checkVersionNotification]); + // Ensure time format useEffect(() => { if (lastSyncTime && !wasTimeFormatSetManually) { ensureTimeFormat(); } }, [lastSyncTime, wasTimeFormatSetManually, ensureTimeFormat]); + // Parse deep link useEffect(() => { if (lastSyncTime && LOCATION_HASH.startsWith('#?tgaddr=')) { processDeepLink(decodeURIComponent(LOCATION_HASH.substr('#?tgaddr='.length)));