diff --git a/protos/SignalStorage.proto b/protos/SignalStorage.proto index f6980b0b64d4..122cb7bc41a5 100644 --- a/protos/SignalStorage.proto +++ b/protos/SignalStorage.proto @@ -145,4 +145,5 @@ message AccountRecord { optional bytes subscriberId = 21; optional string subscriberCurrencyCode = 22; optional bool displayBadgesOnProfile = 23; + optional bool keepMutedChatsArchived = 25; } diff --git a/ts/models/messages.ts b/ts/models/messages.ts index 0ea63aa7f25f..56cd6c914675 100644 --- a/ts/models/messages.ts +++ b/ts/models/messages.ts @@ -2883,6 +2883,11 @@ export class MessageModel extends window.Backbone.Model { const isGroupStoryReply = isGroup(conversation.attributes) && message.get('storyId'); + const keepMutedChatsArchived = + window.storage.get('keepMutedChatsArchived') ?? false; + const keepThisConversationArchived = + keepMutedChatsArchived && conversation.isMuted(); + if (readSyncs.length !== 0 || viewSyncs.length !== 0) { const markReadAt = Math.min( Date.now(), @@ -2922,7 +2927,11 @@ export class MessageModel extends window.Backbone.Model { this.pendingMarkRead ?? Date.now(), markReadAt ); - } else if (isFirstRun && !isGroupStoryReply) { + } else if ( + isFirstRun && + !isGroupStoryReply && + !keepThisConversationArchived + ) { conversation.set({ isArchived: false, }); diff --git a/ts/services/storageRecordOps.ts b/ts/services/storageRecordOps.ts index 6c599d07204a..0ab34119f36b 100644 --- a/ts/services/storageRecordOps.ts +++ b/ts/services/storageRecordOps.ts @@ -315,9 +315,14 @@ export function toAccountRecord( if (typeof subscriberCurrencyCode === 'string') { accountRecord.subscriberCurrencyCode = subscriberCurrencyCode; } - accountRecord.displayBadgesOnProfile = Boolean( - window.storage.get('displayBadgesOnProfile') - ); + const displayBadgesOnProfile = window.storage.get('displayBadgesOnProfile'); + if (displayBadgesOnProfile !== undefined) { + accountRecord.displayBadgesOnProfile = displayBadgesOnProfile; + } + const keepMutedChatsArchived = window.storage.get('keepMutedChatsArchived'); + if (keepMutedChatsArchived !== undefined) { + accountRecord.keepMutedChatsArchived = keepMutedChatsArchived; + } applyUnknownFields(accountRecord, conversation); @@ -933,6 +938,7 @@ export async function mergeAccountRecord( subscriberId, subscriberCurrencyCode, displayBadgesOnProfile, + keepMutedChatsArchived, } = accountRecord; const updatedConversations = new Array(); @@ -1124,6 +1130,7 @@ export async function mergeAccountRecord( window.storage.put('subscriberCurrencyCode', subscriberCurrencyCode); } window.storage.put('displayBadgesOnProfile', Boolean(displayBadgesOnProfile)); + window.storage.put('keepMutedChatsArchived', Boolean(keepMutedChatsArchived)); const ourID = window.ConversationController.getOurConversationId(); diff --git a/ts/types/Storage.d.ts b/ts/types/Storage.d.ts index a4791a0d4977..da04db00301a 100644 --- a/ts/types/Storage.d.ts +++ b/ts/types/Storage.d.ts @@ -140,6 +140,7 @@ export type StorageAccessType = { subscriberId: Uint8Array; subscriberCurrencyCode: string; displayBadgesOnProfile: boolean; + keepMutedChatsArchived: boolean; hasAllStoriesMuted: boolean; // Deprecated