Fix ProfileChangeNotification update nickname contactId
This commit is contained in:
parent
3c3a50a193
commit
c14f5c4712
3 changed files with 15 additions and 7 deletions
|
@ -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}
|
||||
>
|
||||
|
|
|
@ -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>;
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Loading…
Reference in a new issue