Support keepMutedChatsArchived flag
This commit is contained in:
parent
e281fbe0e0
commit
7138daf5ef
4 changed files with 22 additions and 4 deletions
|
@ -145,4 +145,5 @@ message AccountRecord {
|
||||||
optional bytes subscriberId = 21;
|
optional bytes subscriberId = 21;
|
||||||
optional string subscriberCurrencyCode = 22;
|
optional string subscriberCurrencyCode = 22;
|
||||||
optional bool displayBadgesOnProfile = 23;
|
optional bool displayBadgesOnProfile = 23;
|
||||||
|
optional bool keepMutedChatsArchived = 25;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2883,6 +2883,11 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
const isGroupStoryReply =
|
const isGroupStoryReply =
|
||||||
isGroup(conversation.attributes) && message.get('storyId');
|
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) {
|
if (readSyncs.length !== 0 || viewSyncs.length !== 0) {
|
||||||
const markReadAt = Math.min(
|
const markReadAt = Math.min(
|
||||||
Date.now(),
|
Date.now(),
|
||||||
|
@ -2922,7 +2927,11 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
this.pendingMarkRead ?? Date.now(),
|
this.pendingMarkRead ?? Date.now(),
|
||||||
markReadAt
|
markReadAt
|
||||||
);
|
);
|
||||||
} else if (isFirstRun && !isGroupStoryReply) {
|
} else if (
|
||||||
|
isFirstRun &&
|
||||||
|
!isGroupStoryReply &&
|
||||||
|
!keepThisConversationArchived
|
||||||
|
) {
|
||||||
conversation.set({
|
conversation.set({
|
||||||
isArchived: false,
|
isArchived: false,
|
||||||
});
|
});
|
||||||
|
|
|
@ -315,9 +315,14 @@ export function toAccountRecord(
|
||||||
if (typeof subscriberCurrencyCode === 'string') {
|
if (typeof subscriberCurrencyCode === 'string') {
|
||||||
accountRecord.subscriberCurrencyCode = subscriberCurrencyCode;
|
accountRecord.subscriberCurrencyCode = subscriberCurrencyCode;
|
||||||
}
|
}
|
||||||
accountRecord.displayBadgesOnProfile = Boolean(
|
const displayBadgesOnProfile = window.storage.get('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);
|
applyUnknownFields(accountRecord, conversation);
|
||||||
|
|
||||||
|
@ -933,6 +938,7 @@ export async function mergeAccountRecord(
|
||||||
subscriberId,
|
subscriberId,
|
||||||
subscriberCurrencyCode,
|
subscriberCurrencyCode,
|
||||||
displayBadgesOnProfile,
|
displayBadgesOnProfile,
|
||||||
|
keepMutedChatsArchived,
|
||||||
} = accountRecord;
|
} = accountRecord;
|
||||||
|
|
||||||
const updatedConversations = new Array<ConversationModel>();
|
const updatedConversations = new Array<ConversationModel>();
|
||||||
|
@ -1124,6 +1130,7 @@ export async function mergeAccountRecord(
|
||||||
window.storage.put('subscriberCurrencyCode', subscriberCurrencyCode);
|
window.storage.put('subscriberCurrencyCode', subscriberCurrencyCode);
|
||||||
}
|
}
|
||||||
window.storage.put('displayBadgesOnProfile', Boolean(displayBadgesOnProfile));
|
window.storage.put('displayBadgesOnProfile', Boolean(displayBadgesOnProfile));
|
||||||
|
window.storage.put('keepMutedChatsArchived', Boolean(keepMutedChatsArchived));
|
||||||
|
|
||||||
const ourID = window.ConversationController.getOurConversationId();
|
const ourID = window.ConversationController.getOurConversationId();
|
||||||
|
|
||||||
|
|
1
ts/types/Storage.d.ts
vendored
1
ts/types/Storage.d.ts
vendored
|
@ -140,6 +140,7 @@ export type StorageAccessType = {
|
||||||
subscriberId: Uint8Array;
|
subscriberId: Uint8Array;
|
||||||
subscriberCurrencyCode: string;
|
subscriberCurrencyCode: string;
|
||||||
displayBadgesOnProfile: boolean;
|
displayBadgesOnProfile: boolean;
|
||||||
|
keepMutedChatsArchived: boolean;
|
||||||
hasAllStoriesMuted: boolean;
|
hasAllStoriesMuted: boolean;
|
||||||
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
|
|
Loading…
Reference in a new issue