Load messages when showConversation is called in other tab

This commit is contained in:
Jamie Kyle 2023-08-29 17:09:59 -07:00 committed by GitHub
parent 930b2145be
commit 80a19d39de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 19 deletions

View file

@ -3963,6 +3963,12 @@ function showConversation({
// notify composer in case we need to stop recording a voice note
if (conversations.selectedConversationId) {
dispatch(handleLeaveConversation(conversations.selectedConversationId));
dispatch(
onConversationClosed(
conversations.selectedConversationId,
'showConversation'
)
);
}
dispatch({

View file

@ -1,7 +1,7 @@
// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React, { useEffect } from 'react';
import React, { useEffect, useRef } from 'react';
import { useSelector } from 'react-redux';
import { ChatsTab } from '../../components/ChatsTab';
import { SmartConversationView } from './ConversationView';
@ -57,17 +57,11 @@ export function SmartChatsTab(): JSX.Element {
const { showWhatsNewModal } = useGlobalModalActions();
const { toggleNavTabsCollapse } = useItemsActions();
const prevConversationId = usePrevious(
selectedConversationId,
selectedConversationId
);
const lastOpenedConversationId = useRef<string | undefined>();
useEffect(() => {
if (prevConversationId !== selectedConversationId) {
if (prevConversationId) {
onConversationClosed(prevConversationId, 'opened another conversation');
}
if (selectedConversationId !== lastOpenedConversationId.current) {
lastOpenedConversationId.current = selectedConversationId;
if (selectedConversationId) {
onConversationOpened(selectedConversationId, targetedMessage);
}
@ -78,7 +72,20 @@ export function SmartChatsTab(): JSX.Element {
) {
scrollToMessage(selectedConversationId, targetedMessage);
}
}, [
onConversationOpened,
selectedConversationId,
scrollToMessage,
targetedMessage,
targetedMessageSource,
]);
const prevConversationId = usePrevious(
selectedConversationId,
selectedConversationId
);
useEffect(() => {
if (
selectedConversationId != null &&
selectedConversationId !== prevConversationId
@ -89,15 +96,7 @@ export function SmartChatsTab(): JSX.Element {
strictAssert(conversation, 'Conversation must be found');
conversation.setMarkedUnread(false);
}
}, [
onConversationClosed,
onConversationOpened,
prevConversationId,
scrollToMessage,
selectedConversationId,
targetedMessage,
targetedMessageSource,
]);
}, [prevConversationId, selectedConversationId]);
useEffect(() => {
function refreshConversation({

View file

@ -2884,6 +2884,13 @@
"updated": "2023-06-02T00:37:19.861Z",
"reasonDetail": "Reading from innerHTML, not setting it"
},
{
"rule": "React-useRef",
"path": "ts/state/smart/ChatsTab.tsx",
"line": " const lastOpenedConversationId = useRef<string | undefined>();",
"reasonCategory": "usageTrusted",
"updated": "2023-08-25T17:37:23.002Z"
},
{
"rule": "React-useRef",
"path": "ts/state/smart/ConversationPanel.tsx",