Fix ProfileChangeNotification update nickname contactId

This commit is contained in:
Jamie Kyle 2024-03-28 15:20:45 -07:00 committed by GitHub
parent 3c3a50a193
commit c14f5c4712
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 7 deletions

View file

@ -1,7 +1,7 @@
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import React, { useCallback } from 'react';
import type { LocalizerType } from '../../types/Util';
import type { ConversationType } from '../../state/ducks/conversations';
@ -16,7 +16,7 @@ export type PropsType = {
change: ProfileNameChangeType;
changedContact: ConversationType;
i18n: LocalizerType;
onOpenEditNicknameAndNoteModal: () => void;
onOpenEditNicknameAndNoteModal: (contactId: string) => void;
};
export function ProfileChangeNotification({
@ -26,6 +26,11 @@ export function ProfileChangeNotification({
onOpenEditNicknameAndNoteModal,
}: PropsType): JSX.Element {
const message = getStringForProfileChange(change, changedContact, i18n);
const { id: contactId } = changedContact;
const handleOpenEditNicknameAndNoteModal = useCallback(() => {
onOpenEditNicknameAndNoteModal(contactId);
}, [contactId, onOpenEditNicknameAndNoteModal]);
return (
<SystemMessage
@ -35,7 +40,7 @@ export function ProfileChangeNotification({
areNicknamesEnabled() &&
changedContact.nicknameGivenName != null && (
<Button
onClick={onOpenEditNicknameAndNoteModal}
onClick={handleOpenEditNicknameAndNoteModal}
size={ButtonSize.Small}
variant={ButtonVariant.SystemMessage}
>

View file

@ -181,7 +181,7 @@ type PropsLocalType = {
isTargeted: boolean;
targetMessage: (messageId: string, conversationId: string) => unknown;
shouldRenderDateHeader: boolean;
onOpenEditNicknameAndNoteModal: () => void;
onOpenEditNicknameAndNoteModal: (contactId: string) => void;
onOpenMessageRequestActionsConfirmation(state: MessageRequestState): void;
platform: string;
renderContact: SmartContactRendererType<JSX.Element>;

View file

@ -156,9 +156,12 @@ export const SmartTimelineItem = memo(function SmartTimelineItem(
returnToActiveCall,
} = useCallingActions();
const onOpenEditNicknameAndNoteModal = useCallback(() => {
toggleEditNicknameAndNoteModal({ conversationId });
}, [conversationId, toggleEditNicknameAndNoteModal]);
const onOpenEditNicknameAndNoteModal = useCallback(
(contactId: string) => {
toggleEditNicknameAndNoteModal({ conversationId: contactId });
},
[toggleEditNicknameAndNoteModal]
);
const onOpenMessageRequestActionsConfirmation = useCallback(
(state: MessageRequestState) => {