Change keysPending flag to keyExchangeStatus in conversation model

pull/11/head
sachaaaaa 7 years ago
parent 583fb2e6c6
commit ecd300d68d

@ -76,7 +76,7 @@
return { return {
unreadCount: 0, unreadCount: 0,
verified: textsecure.storage.protocol.VerifiedStatus.DEFAULT, verified: textsecure.storage.protocol.VerifiedStatus.DEFAULT,
keysPending: true keyExchangeStatus: 'none'
}; };
}, },
@ -398,29 +398,36 @@
return contact.isVerified(); return contact.isVerified();
}); });
}, },
isKeysPending() { getKeyExchangeStatus() {
if (this.isPrivate()) { return this.get('keyExchangeStatus') || 'none';
if (this.isMe()) { },
return false; isKeyExchangeCompleted() {
} if (!this.isPrivate()) {
const keysPending = this.get('keysPending'); throw new Error(
if (keysPending === undefined) { 'isKeyExchangeCompleted not implemented for groups'
keysPending = true; );
}
return keysPending;
} }
throw new Error( if (this.isMe()) {
'isKeysPending not implemented for groups' return true;
); }
return this.getKeyExchangeStatus() == 'completed';
}, },
setKeysPending(keysPending) { setKeyExchangeStatus(status) {
if (typeof keysPending !== 'boolean') { if (typeof status !== 'string') {
throw new Error(
'setKeyExchangeStatus expects a string'
);
}
status = status.toLowerCase();
if (['none', 'ongoing', 'completed'].indexOf(status) < 0) {
throw new Error( throw new Error(
'setKeysPending expects a boolean' 'unknown string value given to setKeyExchangeStatus'
); );
} }
this.set({ keysPending }); this.set({ keyExchangeStatus: status });
}, },
isUnverified() { isUnverified() {
if (this.isPrivate()) { if (this.isPrivate()) {

@ -160,7 +160,7 @@
color: this.model.getColor(), color: this.model.getColor(),
avatarPath, avatarPath,
isVerified: this.model.isVerified(), isVerified: this.model.isVerified(),
isKeysPending: this.model.isKeysPending(), isKeysPending: this.model.isKeyExchangeCompleted() == false,
isMe: this.model.isMe(), isMe: this.model.isMe(),
isGroup: !this.model.isPrivate(), isGroup: !this.model.isPrivate(),
expirationSettingName, expirationSettingName,

Loading…
Cancel
Save