diff --git a/ts/models/conversations.preload.ts b/ts/models/conversations.preload.ts index 1e79f3968e..25c89662c9 100644 --- a/ts/models/conversations.preload.ts +++ b/ts/models/conversations.preload.ts @@ -1571,7 +1571,7 @@ export class ConversationModel { // The message is being sent before the user has scrolled down to load the newest // messages into memory; in that case, we scroll the user all the way down by // loading the newest message - drop(this.loadNewestMessages(newestId, undefined)); + drop(this.loadNewestMessages(message.id, undefined)); } else if ( // The message has to be not a story or has to be a story reply in direct // conversation. diff --git a/ts/state/smart/LeftPane.preload.tsx b/ts/state/smart/LeftPane.preload.tsx index a4f48ae58d..24ce78a567 100644 --- a/ts/state/smart/LeftPane.preload.tsx +++ b/ts/state/smart/LeftPane.preload.tsx @@ -294,12 +294,6 @@ const getModeSpecificProps = ( } }; -function preloadConversation(conversationId: string): void { - drop( - window.ConversationController.get(conversationId)?.preloadNewestMessages() - ); -} - async function saveAlerts(alerts: ServerAlertsType): Promise { await itemStorage.put('serverAlerts', alerts); } @@ -402,6 +396,19 @@ export const SmartLeftPane = memo(function SmartLeftPane({ }); }, [changeLocation]); + const maybePreloadConversation = useCallback( + (conversationId: string) => { + if (conversationId !== selectedConversationId) { + drop( + window.ConversationController.get( + conversationId + )?.preloadNewestMessages() + ); + } + }, + [selectedConversationId] + ); + let hasExpiredDialog = false; let unsupportedOSDialogType: 'error' | 'warning' | undefined; if (hasAppExpired) { @@ -469,7 +476,7 @@ export const SmartLeftPane = memo(function SmartLeftPane({ otherTabsUnreadStats={otherTabsUnreadStats} pauseBackupMediaDownload={pauseBackupMediaDownload} preferredWidthFromStorage={preferredWidthFromStorage} - preloadConversation={preloadConversation} + preloadConversation={maybePreloadConversation} removeConversation={removeConversation} renderCaptchaDialog={renderCaptchaDialog} renderCrashReportDialog={renderCrashReportDialog}