fix missing awaits

This commit is contained in:
sachaaaaa 2018-12-03 15:18:23 +11:00
parent 933d7730db
commit df80249cba
4 changed files with 24 additions and 12 deletions

View file

@ -891,13 +891,18 @@
"description": "description":
"Confirmation dialog text that asks the user if they really wish to delete the conversation. Answer buttons use the strings 'ok' and 'cancel'. The deletion is permanent, i.e. it cannot be undone." "Confirmation dialog text that asks the user if they really wish to delete the conversation. Answer buttons use the strings 'ok' and 'cancel'. The deletion is permanent, i.e. it cannot be undone."
}, },
"sessionResetFailed": {
"message": "Secure session reset failed",
"description":
"your secure session could not been transmitted to the other participant."
},
"sessionResetOngoing": { "sessionResetOngoing": {
"message": "Secure session reset in progress", "message": "Secure session reset in progress",
"description": "description":
"your secure session is currently being reset, waiting for the reset acknowledgment." "your secure session is currently being reset, waiting for the reset acknowledgment."
}, },
"sessionEnded": { "sessionEnded": {
"message": "Secure session reset done", "message": "Secure session reset succeeded",
"description": "description":
"This is a past tense, informational message. In other words, your secure session has been reset." "This is a past tense, informational message. In other words, your secure session has been reset."
}, },

View file

@ -1443,13 +1443,13 @@
} }
}, },
async onSessionResetInitiated() { async onSessionResetInitiated() {
this.setSessionResetStatus(SessionResetEnum.initiated); await this.setSessionResetStatus(SessionResetEnum.initiated);
}, },
async onSessionResetReceived() { async onSessionResetReceived() {
this.setSessionResetStatus(SessionResetEnum.request_received); await this.setSessionResetStatus(SessionResetEnum.request_received);
// send empty message, this will trigger the new session to propagate // send empty message, this will trigger the new session to propagate
// to the reset initiator. // to the reset initiator.
window.libloki.sendEmptyMessage(this.id); await window.libloki.sendEmptyMessage(this.id);
}, },
isSessionResetReceived() { isSessionResetReceived() {
@ -1479,25 +1479,30 @@
async onNewSessionAdopted() { async onNewSessionAdopted() {
if (this.get('sessionResetStatus') === SessionResetEnum.initiated) { if (this.get('sessionResetStatus') === SessionResetEnum.initiated) {
// send empty message to confirm that we have adopted the new session // send empty message to confirm that we have adopted the new session
window.libloki.sendEmptyMessage(this.id); await window.libloki.sendEmptyMessage(this.id);
} }
this.createAndStoreEndSessionMessage('done'); await this.createAndStoreEndSessionMessage('done');
this.setSessionResetStatus(SessionResetEnum.none); await this.setSessionResetStatus(SessionResetEnum.none);
}, },
async endSession() { async endSession() {
if (this.isPrivate()) { if (this.isPrivate()) {
// Only create a new message if we initiated the session reset. // Only create a new message if *we* initiated the session reset.
// On the receiver side, the actual message containing the END_SESSION flag // On the receiver side, the actual message containing the END_SESSION flag
// will ensure the "session reset" message will be added to their conversation. // will ensure the "session reset" message will be added to their conversation.
if (this.get('sessionResetStatus') === SessionResetEnum.initiated) { if (this.get('sessionResetStatus') === SessionResetEnum.none) {
await this.onSessionResetInitiated();
const message = await this.createAndStoreEndSessionMessage('ongoing'); const message = await this.createAndStoreEndSessionMessage('ongoing');
const options = this.getSendOptions(); const options = this.getSendOptions();
message.send( await message.send(
this.wrapSend( this.wrapSend(
textsecure.messaging.resetSession(this.id, message.get('sent_at'), options) textsecure.messaging.resetSession(this.id, message.get('sent_at'), options)
) )
); );
if (message.hasErrors()) {
await this.createAndStoreEndSessionMessage('failed');
await this.setSessionResetStatus(SessionResetEnum.none);
}
} }
} }
}, },

View file

@ -109,8 +109,11 @@
return !!(this.get('flags') & flag); return !!(this.get('flags') & flag);
}, },
getEndSessionTranslationKey() { getEndSessionTranslationKey() {
if (this.get('endSessionType') === 'ongoing') { const sessionType = this.get('endSessionType');
if (sessionType === 'ongoing') {
return 'sessionResetOngoing'; return 'sessionResetOngoing';
} else if (sessionType === 'failed') {
return 'sessionResetFailed';
} }
return 'sessionEnded'; return 'sessionEnded';
}, },

View file

@ -1259,7 +1259,6 @@
}, },
async endSession() { async endSession() {
await this.model.onSessionResetInitiated();
this.model.endSession(); this.model.endSession();
}, },