From 910d652c4de07d9b35801d43fe6be92c07d70493 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:31:55 -0800 Subject: [PATCH] Fix condition in getE164 --- ts/util/createIPCEvents.ts | 12 ++++++------ ts/util/getE164.ts | 5 +++-- ts/util/getTitle.ts | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ts/util/createIPCEvents.ts b/ts/util/createIPCEvents.ts index 727380781e..ad39315be6 100644 --- a/ts/util/createIPCEvents.ts +++ b/ts/util/createIPCEvents.ts @@ -247,12 +247,6 @@ export function createIPCEvents( setPhoneNumberSharingSetting: async (newValue: PhoneNumberSharingMode) => { const account = window.ConversationController.getOurConversationOrThrow(); - // writeProfile fetches the latest profile first so do it before updating - // local data to prevent triggering a conflict. - await writeProfile(getConversation(account), { - keepAvatar: true, - }); - const promises = new Array>(); promises.push(window.storage.put('phoneNumberSharingMode', newValue)); if (newValue === PhoneNumberSharingMode.Everybody) { @@ -264,6 +258,12 @@ export function createIPCEvents( } account.captureChange('phoneNumberSharingMode'); await Promise.all(promises); + + // Write profile after updating storage so that the write has up-to-date + // information. + await writeProfile(getConversation(account), { + keepAvatar: true, + }); }, getHasStoriesDisabled: () => diff --git a/ts/util/getE164.ts b/ts/util/getE164.ts index 2651c5ed33..673c7ae617 100644 --- a/ts/util/getE164.ts +++ b/ts/util/getE164.ts @@ -14,11 +14,12 @@ export function getE164( | 'systemFamilyName' | 'e164' | 'notSharingPhoneNumber' + | 'profileKey' > ): string | undefined { - const { e164, notSharingPhoneNumber = false } = attributes; + const { e164, profileKey, notSharingPhoneNumber = false } = attributes; - if (notSharingPhoneNumber && !isInSystemContacts(attributes)) { + if (notSharingPhoneNumber && profileKey && !isInSystemContacts(attributes)) { return undefined; } diff --git a/ts/util/getTitle.ts b/ts/util/getTitle.ts index c42cb6f03c..01f1a4bc19 100644 --- a/ts/util/getTitle.ts +++ b/ts/util/getTitle.ts @@ -110,7 +110,7 @@ export function getSystemName( export function getNumber( attributes: Pick< ConversationAttributesType, - 'e164' | 'type' | 'notSharingPhoneNumber' + 'e164' | 'type' | 'notSharingPhoneNumber' | 'profileKey' > ): string | undefined { if (!isDirectConversation(attributes)) {