From d850c95099662c33249a1ad547a3e41270698fe3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 16 Mar 2023 12:24:22 +0000 Subject: [PATCH] Respect user cancelling upload flow by dismissing spinner (#10373) --- 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[] = [];