Load messages when showConversation is called in other tab
This commit is contained in:
parent
930b2145be
commit
80a19d39de
3 changed files with 31 additions and 19 deletions
|
@ -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({
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue