From 9e370df2e83a9ac095eaed0b4e03662bf1b98fde Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Mon, 9 May 2022 23:07:02 +0530 Subject: [PATCH] fix: download success toast showing up even if download errors (#1018) --- app/assets/javascripts/UIModels/AppState/FilesState.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/UIModels/AppState/FilesState.ts b/app/assets/javascripts/UIModels/AppState/FilesState.ts index aad700e3a..ddf6bda05 100644 --- a/app/assets/javascripts/UIModels/AppState/FilesState.ts +++ b/app/assets/javascripts/UIModels/AppState/FilesState.ts @@ -34,7 +34,7 @@ export class FilesState { const decryptedBytesArray: Uint8Array[] = [] - await this.application.files.downloadFile(file, async (decryptedBytes, progress) => { + const result = await this.application.files.downloadFile(file, async (decryptedBytes, progress) => { if (isUsingStreamingSaver) { await saver.pushBytes(decryptedBytes) } else { @@ -51,6 +51,10 @@ export class FilesState { } }) + if (result instanceof ClientDisplayableError) { + throw new Error(result.text) + } + if (isUsingStreamingSaver) { await saver.finish() } else {