From 492cc96ad2516874d0b6a25d6312e79064b93ab7 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Fri, 12 Jun 2020 09:47:25 +1000 Subject: [PATCH] updateSessionTimestamp: return false if no write to DB needed --- libtextsecure/message_receiver.js | 2 +- ts/session/protocols/SessionProtocol.ts | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 13ad7596d..4aecb96e2 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -1953,7 +1953,7 @@ MessageReceiver.prototype.extend({ let conversation; try { conversation = window.ConversationController.get(number); - if(conversation) { + if (conversation) { await conversation.onSessionResetReceived(); } else { throw new Error(); diff --git a/ts/session/protocols/SessionProtocol.ts b/ts/session/protocols/SessionProtocol.ts index ea02e3246..79847da82 100644 --- a/ts/session/protocols/SessionProtocol.ts +++ b/ts/session/protocols/SessionProtocol.ts @@ -220,17 +220,15 @@ export class SessionProtocol { timestamp: number | undefined, map: StringToNumberMap ): Promise { - if (!timestamp) { - if (device in map) { - // tslint:disable-next-line: no-dynamic-delete - delete map[device]; - - return true; - } - + if (map[device] === timestamp) { return false; } - map[device] = timestamp; + if (!timestamp) { + // tslint:disable-next-line: no-dynamic-delete + delete map[device]; + } else { + map[device] = timestamp; + } return true; }