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
|
// notify composer in case we need to stop recording a voice note
|
||||||
if (conversations.selectedConversationId) {
|
if (conversations.selectedConversationId) {
|
||||||
dispatch(handleLeaveConversation(conversations.selectedConversationId));
|
dispatch(handleLeaveConversation(conversations.selectedConversationId));
|
||||||
|
dispatch(
|
||||||
|
onConversationClosed(
|
||||||
|
conversations.selectedConversationId,
|
||||||
|
'showConversation'
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2023 Signal Messenger, LLC
|
// Copyright 2023 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { ChatsTab } from '../../components/ChatsTab';
|
import { ChatsTab } from '../../components/ChatsTab';
|
||||||
import { SmartConversationView } from './ConversationView';
|
import { SmartConversationView } from './ConversationView';
|
||||||
|
@ -57,17 +57,11 @@ export function SmartChatsTab(): JSX.Element {
|
||||||
const { showWhatsNewModal } = useGlobalModalActions();
|
const { showWhatsNewModal } = useGlobalModalActions();
|
||||||
const { toggleNavTabsCollapse } = useItemsActions();
|
const { toggleNavTabsCollapse } = useItemsActions();
|
||||||
|
|
||||||
const prevConversationId = usePrevious(
|
const lastOpenedConversationId = useRef<string | undefined>();
|
||||||
selectedConversationId,
|
|
||||||
selectedConversationId
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (prevConversationId !== selectedConversationId) {
|
if (selectedConversationId !== lastOpenedConversationId.current) {
|
||||||
if (prevConversationId) {
|
lastOpenedConversationId.current = selectedConversationId;
|
||||||
onConversationClosed(prevConversationId, 'opened another conversation');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedConversationId) {
|
if (selectedConversationId) {
|
||||||
onConversationOpened(selectedConversationId, targetedMessage);
|
onConversationOpened(selectedConversationId, targetedMessage);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +72,20 @@ export function SmartChatsTab(): JSX.Element {
|
||||||
) {
|
) {
|
||||||
scrollToMessage(selectedConversationId, targetedMessage);
|
scrollToMessage(selectedConversationId, targetedMessage);
|
||||||
}
|
}
|
||||||
|
}, [
|
||||||
|
onConversationOpened,
|
||||||
|
selectedConversationId,
|
||||||
|
scrollToMessage,
|
||||||
|
targetedMessage,
|
||||||
|
targetedMessageSource,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const prevConversationId = usePrevious(
|
||||||
|
selectedConversationId,
|
||||||
|
selectedConversationId
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
selectedConversationId != null &&
|
selectedConversationId != null &&
|
||||||
selectedConversationId !== prevConversationId
|
selectedConversationId !== prevConversationId
|
||||||
|
@ -89,15 +96,7 @@ export function SmartChatsTab(): JSX.Element {
|
||||||
strictAssert(conversation, 'Conversation must be found');
|
strictAssert(conversation, 'Conversation must be found');
|
||||||
conversation.setMarkedUnread(false);
|
conversation.setMarkedUnread(false);
|
||||||
}
|
}
|
||||||
}, [
|
}, [prevConversationId, selectedConversationId]);
|
||||||
onConversationClosed,
|
|
||||||
onConversationOpened,
|
|
||||||
prevConversationId,
|
|
||||||
scrollToMessage,
|
|
||||||
selectedConversationId,
|
|
||||||
targetedMessage,
|
|
||||||
targetedMessageSource,
|
|
||||||
]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function refreshConversation({
|
function refreshConversation({
|
||||||
|
|
|
@ -2884,6 +2884,13 @@
|
||||||
"updated": "2023-06-02T00:37:19.861Z",
|
"updated": "2023-06-02T00:37:19.861Z",
|
||||||
"reasonDetail": "Reading from innerHTML, not setting it"
|
"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",
|
"rule": "React-useRef",
|
||||||
"path": "ts/state/smart/ConversationPanel.tsx",
|
"path": "ts/state/smart/ConversationPanel.tsx",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue