From 6a165da589bac0e3fe6287c41517a50c001df630 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:33:34 -0800 Subject: [PATCH] Update shared groups when opening dialog --- .../conversation/ContactSpoofingReviewDialog.stories.tsx | 1 + .../conversation/ContactSpoofingReviewDialog.tsx | 5 +++++ .../ContactSpoofingReviewDialogPerson.stories.tsx | 1 + .../conversation/ContactSpoofingReviewDialogPerson.tsx | 9 ++++++++- ts/state/smart/ContactSpoofingReviewDialog.tsx | 2 ++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ts/components/conversation/ContactSpoofingReviewDialog.stories.tsx b/ts/components/conversation/ContactSpoofingReviewDialog.stories.tsx index d1c74bcfe8..1c9ac7da11 100644 --- a/ts/components/conversation/ContactSpoofingReviewDialog.stories.tsx +++ b/ts/components/conversation/ContactSpoofingReviewDialog.stories.tsx @@ -31,6 +31,7 @@ const getCommonProps = () => ({ onClose: action('onClose'), showContactModal: action('showContactModal'), toggleSignalConnectionsModal: action('toggleSignalConnectionsModal'), + updateSharedGroups: action('updateSharedGroups'), removeMember: action('removeMember'), theme: ThemeType.light, }); diff --git a/ts/components/conversation/ContactSpoofingReviewDialog.tsx b/ts/components/conversation/ContactSpoofingReviewDialog.tsx index d130ac7f87..194a556313 100644 --- a/ts/components/conversation/ContactSpoofingReviewDialog.tsx +++ b/ts/components/conversation/ContactSpoofingReviewDialog.tsx @@ -54,6 +54,7 @@ export type PropsType = { blockConversation: (conversationId: string) => unknown; deleteConversation: (conversationId: string) => unknown; toggleSignalConnectionsModal: () => void; + updateSharedGroups: (conversationId: string) => void; getPreferredBadge: PreferredBadgeSelectorType; i18n: LocalizerType; onClose: () => void; @@ -79,6 +80,7 @@ export function ContactSpoofingReviewDialog(props: PropsType): JSX.Element { conversationId, deleteConversation, toggleSignalConnectionsModal, + updateSharedGroups, getPreferredBadge, i18n, onClose, @@ -199,6 +201,7 @@ export function ContactSpoofingReviewDialog(props: PropsType): JSX.Element { conversation={possiblyUnsafe.conversation} getPreferredBadge={getPreferredBadge} toggleSignalConnectionsModal={toggleSignalConnectionsModal} + updateSharedGroups={updateSharedGroups} i18n={i18n} theme={theme} isSignalConnection={possiblyUnsafe.isSignalConnection} @@ -235,6 +238,7 @@ export function ContactSpoofingReviewDialog(props: PropsType): JSX.Element { conversation={safe.conversation} getPreferredBadge={getPreferredBadge} toggleSignalConnectionsModal={toggleSignalConnectionsModal} + updateSharedGroups={updateSharedGroups} i18n={i18n} onClick={() => { showContactModal(safe.conversation.id); @@ -328,6 +332,7 @@ export function ContactSpoofingReviewDialog(props: PropsType): JSX.Element { toggleSignalConnectionsModal={ toggleSignalConnectionsModal } + updateSharedGroups={updateSharedGroups} getPreferredBadge={getPreferredBadge} i18n={i18n} theme={theme} diff --git a/ts/components/conversation/ContactSpoofingReviewDialogPerson.stories.tsx b/ts/components/conversation/ContactSpoofingReviewDialogPerson.stories.tsx index 7a7a4bcc36..2203d16509 100644 --- a/ts/components/conversation/ContactSpoofingReviewDialogPerson.stories.tsx +++ b/ts/components/conversation/ContactSpoofingReviewDialogPerson.stories.tsx @@ -26,6 +26,7 @@ export default { i18n, onClick: action('onClick'), toggleSignalConnectionsModal: action('toggleSignalConnectionsModal'), + updateSharedGroups: action('updateSharedGroups'), getPreferredBadge: () => undefined, conversation: getDefaultConversation(), theme: ThemeType.light, diff --git a/ts/components/conversation/ContactSpoofingReviewDialogPerson.tsx b/ts/components/conversation/ContactSpoofingReviewDialogPerson.tsx index 93564da0c0..5426f5bcfe 100644 --- a/ts/components/conversation/ContactSpoofingReviewDialogPerson.tsx +++ b/ts/components/conversation/ContactSpoofingReviewDialogPerson.tsx @@ -2,7 +2,7 @@ // SPDX-License-Identifier: AGPL-3.0-only import type { ReactNode } from 'react'; -import React from 'react'; +import React, { useEffect } from 'react'; import type { ConversationType } from '../../state/ducks/conversations'; import type { LocalizerType, ThemeType } from '../../types/Util'; @@ -22,6 +22,7 @@ export type PropsType = Readonly<{ i18n: LocalizerType; onClick?: () => void; toggleSignalConnectionsModal: () => void; + updateSharedGroups: (conversationId: string) => void; theme: ThemeType; oldName: string | undefined; isSignalConnection: boolean; @@ -34,6 +35,7 @@ export function ContactSpoofingReviewDialogPerson({ i18n, onClick, toggleSignalConnectionsModal, + updateSharedGroups, theme, oldName, isSignalConnection, @@ -43,6 +45,11 @@ export function ContactSpoofingReviewDialogPerson({ ' expected a direct conversation' ); + useEffect(() => { + // Kick off the expensive hydration of the current sharedGroupNames + updateSharedGroups(conversation.id); + }, [conversation.id, updateSharedGroups]); + const newName = conversation.profileName || conversation.title; let callout: JSX.Element | undefined; diff --git a/ts/state/smart/ContactSpoofingReviewDialog.tsx b/ts/state/smart/ContactSpoofingReviewDialog.tsx index 39e7283f69..443b2a4df3 100644 --- a/ts/state/smart/ContactSpoofingReviewDialog.tsx +++ b/ts/state/smart/ContactSpoofingReviewDialog.tsx @@ -48,6 +48,7 @@ export function SmartContactSpoofingReviewDialog( blockConversation, deleteConversation, removeMember, + updateSharedGroups, } = useConversationsActions(); const { showContactModal, toggleSignalConnectionsModal } = useGlobalModalActions(); @@ -79,6 +80,7 @@ export function SmartContactSpoofingReviewDialog( getPreferredBadge, i18n, removeMember, + updateSharedGroups, showContactModal, toggleSignalConnectionsModal, theme,