From ebd69d1eb3a9d693c8fabead898b276ec83ba051 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Fri, 2 Jul 2021 17:43:40 -0700 Subject: [PATCH] Clear profile avatar when we discover that it has been removed --- ts/models/conversations.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index 262e6b890b..b4be7296f3 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -4601,13 +4601,18 @@ export class ConversationModel extends window.Backbone } } - async setProfileAvatar(avatarPath: string): Promise { - if (!avatarPath) { - return; + async setProfileAvatar(avatarPath: undefined | null | string): Promise { + if (isMe(this.attributes)) { + if (avatarPath) { + window.storage.put('avatarUrl', avatarPath); + } else { + window.storage.remove('avatarUrl'); + } } - if (isMe(this.attributes)) { - window.storage.put('avatarUrl', avatarPath); + if (!avatarPath) { + this.set({ profileAvatar: undefined }); + return; } const avatar = await window.textsecure.messaging.getAvatar(avatarPath);