Update conversation.unreadCount in just one place, from database
This commit is contained in:
parent
a9c788b689
commit
d4e0f6a38d
3 changed files with 12 additions and 6 deletions
|
@ -4644,10 +4644,16 @@ export class ConversationModel extends window.Backbone
|
|||
}
|
||||
): Promise<void> {
|
||||
await markConversationRead(this.attributes, newestUnreadAt, options);
|
||||
await this.updateUnread();
|
||||
}
|
||||
|
||||
async updateUnread(): Promise<void> {
|
||||
const unreadCount = await window.Signal.Data.getTotalUnreadForConversation(
|
||||
this.id,
|
||||
{ storyId: undefined, isGroup: isGroup(this.attributes) }
|
||||
{
|
||||
storyId: undefined,
|
||||
isGroup: isGroup(this.attributes),
|
||||
}
|
||||
);
|
||||
|
||||
const prevUnreadCount = this.get('unreadCount');
|
||||
|
|
|
@ -2647,6 +2647,8 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
|
||||
window.Whisper.events.trigger('incrementProgress');
|
||||
confirm();
|
||||
|
||||
conversation.queueJob('updateUnread', () => conversation.updateUnread());
|
||||
}
|
||||
|
||||
// This function is called twice - once from handleDataMessage, and then again from
|
||||
|
@ -2776,7 +2778,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
);
|
||||
} else if (isFirstRun && !isGroupStoryReply) {
|
||||
conversation.set({
|
||||
unreadCount: (conversation.get('unreadCount') || 0) + 1,
|
||||
isArchived: false,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import {
|
|||
import { Address } from '../types/Address';
|
||||
import { QualifiedAddress } from '../types/QualifiedAddress';
|
||||
import { UUID } from '../types/UUID';
|
||||
import { isEnabled } from '../RemoteConfig';
|
||||
import { getValue, isEnabled } from '../RemoteConfig';
|
||||
import { isRecord } from './isRecord';
|
||||
|
||||
import { isOlderThan } from './timestamp';
|
||||
|
@ -55,7 +55,6 @@ import {
|
|||
multiRecipient410ResponseSchema,
|
||||
} from '../textsecure/WebAPI';
|
||||
import { SignalService as Proto } from '../protobuf';
|
||||
import * as RemoteConfig from '../RemoteConfig';
|
||||
|
||||
import { strictAssert } from './assert';
|
||||
import * as log from '../logging/log';
|
||||
|
@ -169,8 +168,8 @@ export async function sendContentMessageToGroup({
|
|||
|
||||
if (
|
||||
isEnabled('desktop.sendSenderKey3') &&
|
||||
isEnabled('desktop.senderKey.send') &&
|
||||
ourConversation?.get('capabilities')?.senderKey &&
|
||||
RemoteConfig.isEnabled('desktop.senderKey.send') &&
|
||||
sendTarget.isValid()
|
||||
) {
|
||||
try {
|
||||
|
@ -681,7 +680,7 @@ const MAX_SENDER_KEY_EXPIRE_DURATION = 90 * DAY;
|
|||
function getSenderKeyExpireDuration(): number {
|
||||
try {
|
||||
const parsed = parseIntOrThrow(
|
||||
window.Signal.RemoteConfig.getValue('desktop.senderKeyMaxAge'),
|
||||
getValue('desktop.senderKeyMaxAge'),
|
||||
'getSenderKeyExpireDuration'
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue