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":
"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": {
"message": "Secure session reset in progress",
"description":
"your secure session is currently being reset, waiting for the reset acknowledgment."
},
"sessionEnded": {
"message": "Secure session reset done",
"message": "Secure session reset succeeded",
"description":
"This is a past tense, informational message. In other words, your secure session has been reset."
},

View file

@ -1443,13 +1443,13 @@
}
},
async onSessionResetInitiated() {
this.setSessionResetStatus(SessionResetEnum.initiated);
await this.setSessionResetStatus(SessionResetEnum.initiated);
},
async onSessionResetReceived() {
this.setSessionResetStatus(SessionResetEnum.request_received);
await this.setSessionResetStatus(SessionResetEnum.request_received);
// send empty message, this will trigger the new session to propagate
// to the reset initiator.
window.libloki.sendEmptyMessage(this.id);
await window.libloki.sendEmptyMessage(this.id);
},
isSessionResetReceived() {
@ -1479,25 +1479,30 @@
async onNewSessionAdopted() {
if (this.get('sessionResetStatus') === SessionResetEnum.initiated) {
// 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');
this.setSessionResetStatus(SessionResetEnum.none);
await this.createAndStoreEndSessionMessage('done');
await this.setSessionResetStatus(SessionResetEnum.none);
},
async endSession() {
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
// 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 options = this.getSendOptions();
message.send(
await message.send(
this.wrapSend(
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);
},
getEndSessionTranslationKey() {
if (this.get('endSessionType') === 'ongoing') {
const sessionType = this.get('endSessionType');
if (sessionType === 'ongoing') {
return 'sessionResetOngoing';
} else if (sessionType === 'failed') {
return 'sessionResetFailed';
}
return 'sessionEnded';
},

View file

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