From a956de12f00a775cfb9e0b681b0edb4328ba42f8 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Tue, 21 Feb 2023 18:28:05 +0100 Subject: [PATCH] Message List: Fix old messages loading when opening shared media (#2638) --- src/components/right/Profile.tsx | 48 +++++++++++---------------- src/global/actions/api/localSearch.ts | 2 -- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/src/components/right/Profile.tsx b/src/components/right/Profile.tsx index 7ae002a5a..b0d8d2e91 100644 --- a/src/components/right/Profile.tsx +++ b/src/components/right/Profile.tsx @@ -35,11 +35,9 @@ import { selectTheme, selectActiveDownloadIds, selectUser, - selectListedIds, } from '../../global/selectors'; import { captureEvents, SwipeDirection } from '../../util/captureEvents'; import { getSenderName } from '../left/search/helpers/getSenderName'; -import { pickTruthy } from '../../util/iteratees'; import useCacheBuster from '../../hooks/useCacheBuster'; import useProfileViewportIds from './hooks/useProfileViewportIds'; import useProfileState from './hooks/useProfileState'; @@ -82,7 +80,6 @@ type StateProps = { currentUserId?: string; resolvedUserId?: string; messagesById?: Record; - messageIds?: number[]; foundIds?: number[]; mediaSearchType?: SharedMediaType; hasCommonChatsTab?: boolean; @@ -124,7 +121,6 @@ const Profile: FC = ({ currentUserId, messagesById, foundIds, - messageIds, mediaSearchType, hasCommonChatsTab, hasMembersTab, @@ -178,10 +174,6 @@ const Profile: FC = ({ const renderingActiveTab = activeTab > tabs.length - 1 ? tabs.length - 1 : activeTab; const tabType = tabs[renderingActiveTab].type as ProfileTabType; - const chatMessages = useMemo(() => { - return messageIds && messagesById ? pickTruthy(messagesById, messageIds) : {}; - }, [messagesById, messageIds]); - const [resultType, viewportIds, getMore, noProfileInfo] = useProfileViewportIds( loadMoreMembers, loadCommonChats, @@ -193,7 +185,7 @@ const Profile: FC = ({ usersById, userStatusesById, chatsById, - chatMessages, + messagesById, foundIds, lastSyncTime, topicId, @@ -311,7 +303,7 @@ const Profile: FC = ({ } function renderContent() { - if (!viewportIds || !canRenderContent || !chatMessages) { + if (!viewportIds || !canRenderContent || !messagesById) { const noSpinner = isFirstTab && !canRenderContent; const forceRenderHiddenMembers = Boolean(resultType === 'members' && areMembersHidden); @@ -363,20 +355,20 @@ const Profile: FC = ({ teactFastList > {resultType === 'media' ? ( - (viewportIds as number[])!.map((id) => chatMessages[id] && ( + (viewportIds as number[])!.map((id) => messagesById[id] && ( )) ) : resultType === 'documents' ? ( - (viewportIds as number[])!.map((id) => chatMessages[id] && ( + (viewportIds as number[])!.map((id) => messagesById[id] && ( = ({ /> )) ) : resultType === 'links' ? ( - (viewportIds as number[])!.map((id) => chatMessages[id] && ( + (viewportIds as number[])!.map((id) => messagesById[id] && ( )) ) : resultType === 'audio' ? ( - (viewportIds as number[])!.map((id) => chatMessages[id] && ( + (viewportIds as number[])!.map((id) => messagesById[id] && (