From 496bdec35dda0f9ac253da6ce6b1da840576be4a Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Wed, 9 Dec 2020 14:57:34 -0600 Subject: [PATCH] Fix duplicate timeline items for group call events --- ts/models/conversations.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index c1d0c78ea..86df5e0a7 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -2097,9 +2097,12 @@ export class ConversationModel extends window.Backbone.Model< eraId: string, creatorUuid: string ): Promise { + // We want to update the cache quickly in case this function is called multiple times. + const oldCachedEraId = this.cachedLatestGroupCallEraId; + this.cachedLatestGroupCallEraId = eraId; + const alreadyHasMessage = - (this.cachedLatestGroupCallEraId && - this.cachedLatestGroupCallEraId === eraId) || + (oldCachedEraId && oldCachedEraId === eraId) || (await window.Signal.Data.hasGroupCallHistoryMessage(this.id, eraId)); if (!alreadyHasMessage) { @@ -2110,8 +2113,6 @@ export class ConversationModel extends window.Backbone.Model< startedTime: Date.now(), }); } - - this.cachedLatestGroupCallEraId = eraId; } async addProfileChange(