From e049934510e3a4f71d9206332b608dcb6b42229f Mon Sep 17 00:00:00 2001 From: warrickct Date: Thu, 17 Feb 2022 15:05:13 +1100 Subject: [PATCH] Handling approval edge cases for restoring devices. --- ts/models/conversation.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 9eecf7fb1..dc5172c3e 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -923,6 +923,14 @@ export class ConversationModel extends Backbone.Model { 'conversationId' | 'source' | 'type' | 'direction' | 'received_at' > ) { + // for handling edge case for syncing/linking devices. + // if convo has a message by us, we have replied - which is considered as approved + if (!this.isMe()) { + if (!this.isApproved() && this.isPrivate()) { + this.setIsApproved(true); + } + } + return this.addSingleMessage({ ...messageAttributes, conversationId: this.id, @@ -936,6 +944,11 @@ export class ConversationModel extends Backbone.Model { public async addSingleIncomingMessage( messageAttributes: Omit ) { + // if there's a message by the other user, they've replied to us which we consider an accepted convo + if (!this.didApproveMe() && this.isPrivate()) { + this.setDidApproveMe(true); + } + return this.addSingleMessage({ ...messageAttributes, conversationId: this.id,