From 05f848a11dddfb1eb93ad84cb2f7730a575cd318 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 14 Mar 2023 11:05:48 +0000 Subject: [PATCH] Respect user cancelling upload flow by dismissing spinner --- src/ContentMessages.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ContentMessages.ts b/src/ContentMessages.ts index b5309d8ee2c..f022f5e4f89 100644 --- a/src/ContentMessages.ts +++ b/src/ContentMessages.ts @@ -378,8 +378,13 @@ export default class ContentMessages { if (!this.mediaConfig) { // hot-path optimization to not flash a spinner if we don't need to const modal = Modal.createDialog(Spinner, undefined, "mx_Dialog_spinner"); - await this.ensureMediaConfigFetched(matrixClient); - modal.close(); + await Promise.race([this.ensureMediaConfigFetched(matrixClient), modal.finished]); + if (!this.mediaConfig) { + // User cancelled by clicking away on the spinner + return; + } else { + modal.close(); + } } const tooBigFiles: File[] = [];