From ecd300d68d841e5b5329c795e1be0e7b29a70f36 Mon Sep 17 00:00:00 2001 From: sachaaaaa Date: Mon, 15 Oct 2018 15:49:18 +1100 Subject: [PATCH 1/2] Change keysPending flag to keyExchangeStatus in conversation model --- js/models/conversations.js | 43 ++++++++++++++++++++--------------- js/views/conversation_view.js | 2 +- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index 774b4207c..f96aa672b 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -76,7 +76,7 @@ return { unreadCount: 0, verified: textsecure.storage.protocol.VerifiedStatus.DEFAULT, - keysPending: true + keyExchangeStatus: 'none' }; }, @@ -398,29 +398,36 @@ return contact.isVerified(); }); }, - isKeysPending() { - if (this.isPrivate()) { - if (this.isMe()) { - return false; - } - const keysPending = this.get('keysPending'); - if (keysPending === undefined) { - keysPending = true; - } - return keysPending; + getKeyExchangeStatus() { + return this.get('keyExchangeStatus') || 'none'; + }, + isKeyExchangeCompleted() { + if (!this.isPrivate()) { + throw new Error( + 'isKeyExchangeCompleted not implemented for groups' + ); } - throw new Error( - 'isKeysPending not implemented for groups' - ); + if (this.isMe()) { + return true; + } + + return this.getKeyExchangeStatus() == 'completed'; }, - setKeysPending(keysPending) { - if (typeof keysPending !== 'boolean') { + setKeyExchangeStatus(status) { + if (typeof status !== 'string') { + throw new Error( + 'setKeyExchangeStatus expects a string' + ); + } + status = status.toLowerCase(); + + if (['none', 'ongoing', 'completed'].indexOf(status) < 0) { throw new Error( - 'setKeysPending expects a boolean' + 'unknown string value given to setKeyExchangeStatus' ); } - this.set({ keysPending }); + this.set({ keyExchangeStatus: status }); }, isUnverified() { if (this.isPrivate()) { diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index a91b9e536..b26a6bbc6 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -160,7 +160,7 @@ color: this.model.getColor(), avatarPath, isVerified: this.model.isVerified(), - isKeysPending: this.model.isKeysPending(), + isKeysPending: this.model.isKeyExchangeCompleted() == false, isMe: this.model.isMe(), isGroup: !this.model.isPrivate(), expirationSettingName, From d5ef0cfb031bc64248caaf26f494337e4f323f2f Mon Sep 17 00:00:00 2001 From: sachaaaaa Date: Wed, 17 Oct 2018 13:56:11 +1100 Subject: [PATCH 2/2] Revert changes and rename keysPending to keyExchangeCompleted --- js/models/conversations.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index f96aa672b..afd7e73ee 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -76,7 +76,7 @@ return { unreadCount: 0, verified: textsecure.storage.protocol.VerifiedStatus.DEFAULT, - keyExchangeStatus: 'none' + keyExchangeCompleted: false, }; }, @@ -398,9 +398,6 @@ return contact.isVerified(); }); }, - getKeyExchangeStatus() { - return this.get('keyExchangeStatus') || 'none'; - }, isKeyExchangeCompleted() { if (!this.isPrivate()) { throw new Error( @@ -412,22 +409,16 @@ return true; } - return this.getKeyExchangeStatus() == 'completed'; + return this.get('keyExchangeCompleted') || false; }, - setKeyExchangeStatus(status) { - if (typeof status !== 'string') { + setKeyExchangeCompleted(completed) { + if (typeof completed !== 'boolean') { throw new Error( - 'setKeyExchangeStatus expects a string' + 'setKeyExchangeCompleted expects a bool' ); } - status = status.toLowerCase(); - if (['none', 'ongoing', 'completed'].indexOf(status) < 0) { - throw new Error( - 'unknown string value given to setKeyExchangeStatus' - ); - } - this.set({ keyExchangeStatus: status }); + this.set({ keyExchangeCompleted: completed }); }, isUnverified() { if (this.isPrivate()) {