From 0d87bbb5eb08b197980cceb4a93bbc3bc413fa4c Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 5 Feb 2025 10:36:55 +1000 Subject: [PATCH] getProfile: Only clear profile name if profile is missing it --- ts/services/profiles.ts | 4 ---- ts/services/storageRecordOps.ts | 18 +++++++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ts/services/profiles.ts b/ts/services/profiles.ts index 5e6d34794..a049b1760 100644 --- a/ts/services/profiles.ts +++ b/ts/services/profiles.ts @@ -771,10 +771,6 @@ async function doGetProfile( Errors.toLogFormat(error) ); isSuccessfullyDecrypted = false; - c.set({ - profileName: undefined, - profileFamilyName: undefined, - }); } } } else { diff --git a/ts/services/storageRecordOps.ts b/ts/services/storageRecordOps.ts index fa2cb7411..4f24f7e65 100644 --- a/ts/services/storageRecordOps.ts +++ b/ts/services/storageRecordOps.ts @@ -1182,20 +1182,24 @@ export async function mergeContactRecord( remoteName && (localName !== remoteName || localFamilyName !== remoteFamilyName) ) { - // Local name doesn't match remote name, fetch profile + log.info( + `mergeContactRecord: ${conversation.idForLogging()} name doesn't match remote name; overwriting` + ); + details.push('updated profile name'); + conversation.set({ + profileName: remoteName, + profileFamilyName: remoteFamilyName, + }); if (localName) { + log.info( + `mergeContactRecord: ${conversation.idForLogging()} name doesn't match remote name; also fetching profile` + ); drop( conversation.getProfiles().catch(() => { /* nothing to do here; logging already happened */ }) ); details.push('refreshing profile'); - } else { - conversation.set({ - profileName: remoteName, - profileFamilyName: remoteFamilyName, - }); - details.push('updated profile name'); } } conversation.set({