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)) {