From 7859bb97fa171914c8c6c3679378209e69cdac6b Mon Sep 17 00:00:00 2001 From: zubiden <19638254+zubiden@users.noreply.github.com> Date: Fri, 27 Sep 2024 16:11:40 +0200 Subject: [PATCH] Forum: Fix topic preview disappearing after sync (#5023) --- src/components/left/main/Chat.tsx | 7 +++++-- src/components/left/search/BotAppResults.tsx | 6 +----- src/components/middle/message/SimilarChannels.tsx | 7 ++----- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/components/left/main/Chat.tsx b/src/components/left/main/Chat.tsx index 177b868ef..321b02d5a 100644 --- a/src/components/left/main/Chat.tsx +++ b/src/components/left/main/Chat.tsx @@ -113,6 +113,7 @@ type StateProps = { lastMessageId?: number; lastMessage?: ApiMessage; currentUserId: string; + isSynced?: boolean; }; const Chat: FC = ({ @@ -150,6 +151,7 @@ const Chat: FC = ({ isPreview, previewMessageId, className, + isSynced, onDragEnter, }) => { const { @@ -290,10 +292,10 @@ const Chat: FC = ({ // Load the forum topics to display unread count badge useEffect(() => { - if (isIntersecting && isForum && listedTopicIds === undefined) { + if (isIntersecting && isForum && isSynced && listedTopicIds === undefined) { loadTopics({ chatId }); } - }, [chatId, listedTopicIds, isForum, isIntersecting]); + }, [chatId, listedTopicIds, isSynced, isForum, isIntersecting]); const isOnline = user && userStatus && isUserOnline(user, userStatus); const { hasShownClass: isAvatarOnlineShown } = useShowTransitionDeprecated(isOnline); @@ -501,6 +503,7 @@ export default memo(withGlobal( currentUserId: global.currentUserId!, listedTopicIds: topicsInfo?.listedTopicIds, topics: topicsInfo?.topicsById, + isSynced: global.isSynced, }; }, )(Chat)); diff --git a/src/components/left/search/BotAppResults.tsx b/src/components/left/search/BotAppResults.tsx index 00ac59f65..89f8e8cc3 100644 --- a/src/components/left/search/BotAppResults.tsx +++ b/src/components/left/search/BotAppResults.tsx @@ -27,7 +27,6 @@ export type OwnProps = { }; type StateProps = { - isSynced?: boolean; isLoading?: boolean; foundIds?: string[]; recentBotIds?: string[]; @@ -38,7 +37,6 @@ const runThrottled = throttle((cb) => cb(), 500, true); const BotAppResults: FC = ({ searchQuery, - isSynced, isLoading, foundIds, recentBotIds, @@ -69,13 +67,12 @@ const BotAppResults: FC = ({ }); const handleLoadMore = useCallback(({ direction }: { direction: LoadMoreDirection }) => { - if (!isSynced) return; if (direction === LoadMoreDirection.Backwards) { runThrottled(() => { searchPopularBotApps(); }); } - }, [isSynced]); + }, []); const handleToggleShowMoreMine = useLastCallback(() => { setShouldShowMoreMine((prev) => !prev); @@ -145,7 +142,6 @@ export default memo(withGlobal((global) => { const foundIds = globalSearch.popularBotApps?.peerIds; return { - isSynced: global.isSynced, isLoading: !foundIds && globalSearch.fetchingStatus?.botApps, foundIds, recentBotIds: global.topBotApps.userIds, diff --git a/src/components/middle/message/SimilarChannels.tsx b/src/components/middle/message/SimilarChannels.tsx index 3b0ad288b..01cf4540e 100644 --- a/src/components/middle/message/SimilarChannels.tsx +++ b/src/components/middle/message/SimilarChannels.tsx @@ -41,7 +41,6 @@ type StateProps = { shouldShowInChat?: boolean; count: number; isCurrentUserPremium: boolean; - isSynced?: boolean; }; const SimilarChannels = ({ @@ -50,7 +49,6 @@ const SimilarChannels = ({ shouldShowInChat, count, isCurrentUserPremium, - isSynced, }: StateProps & OwnProps) => { const lang = useOldLang(); const { toggleChannelRecommendations, loadChannelRecommendations } = getActions(); @@ -80,10 +78,10 @@ const SimilarChannels = ({ ); useEffect(() => { - if (isSynced && !similarChannelIds) { + if (!similarChannelIds) { loadChannelRecommendations({ chatId }); } - }, [chatId, isSynced, similarChannelIds]); + }, [chatId, similarChannelIds]); useTimeout(() => setShoulRenderSkeleton(false), MAX_SKELETON_DELAY); @@ -249,7 +247,6 @@ export default memo( shouldShowInChat, count, isCurrentUserPremium, - isSynced: global.isSynced, }; })(SimilarChannels), );