From e2cb9b6bef54a1bc04174aa9eec02ea800962887 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 4 May 2021 16:26:26 +0200 Subject: [PATCH] Include encrypt in formPromise (#368) * Include encrypt in formPromise --- .../components/send/add-edit.component.ts | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/angular/components/send/add-edit.component.ts b/src/angular/components/send/add-edit.component.ts index 4ba73fb2a1f..31bee204a0c 100644 --- a/src/angular/components/send/add-edit.component.ts +++ b/src/angular/components/send/add-edit.component.ts @@ -299,27 +299,30 @@ export class AddEditComponent implements OnInit { this.password = null; } - const encSend = await this.encryptSend(file); - try { - this.formPromise = this.sendService.saveWithServer(encSend); - let inactive = false; - setTimeout(() => inactive = true, 4500); - await this.formPromise; - if (this.send.id == null) { - this.send.id = encSend[0].id; - } - if (this.send.accessId == null) { - this.send.accessId = encSend[0].accessId; - } - this.onSavedSend.emit(this.send); - await this.showSuccessMessage(inactive); - if (this.copyLink) { - this.copyLinkToClipboard(this.link); - } - return true; - } catch { } + this.formPromise = this.encryptSend(file) + .then(async encSend => { + try { + const uploadPromise = this.sendService.saveWithServer(encSend); + let inactive = false; + setTimeout(() => inactive = true, 4500); + await uploadPromise; + if (this.send.id == null) { + this.send.id = encSend[0].id; + } + if (this.send.accessId == null) { + this.send.accessId = encSend[0].accessId; + } + this.onSavedSend.emit(this.send); + await this.showSuccessMessage(inactive); + if (this.copyLink) { + this.copyLinkToClipboard(this.link); + } + return true; + } catch { } + return false; + }); - return false; + return await this.formPromise; } async showSuccessMessage(inactive: boolean) {