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,