From 2798942a945c9c2595304420516e83000dfbc052 Mon Sep 17 00:00:00 2001 From: Matthew Diamant Date: Wed, 12 Mar 2025 15:47:02 -0700 Subject: [PATCH] Extensions load in background and show pending state (#1657) Co-authored-by: Lily Delalande <119957291+lily-de@users.noreply.github.com> --- ui/desktop/src/extensions.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/desktop/src/extensions.ts b/ui/desktop/src/extensions.ts index b177ee21..cf06fb59 100644 --- a/ui/desktop/src/extensions.ts +++ b/ui/desktop/src/extensions.ts @@ -80,6 +80,9 @@ export async function addExtension( timeout: extension.timeout, }; + let toastId; + if (!silent) toastId = toast.loading(`Adding ${extension.name} extension...`); + const response = await fetch(getApiUrl('/extensions/add'), { method: 'POST', headers: { @@ -93,6 +96,7 @@ export async function addExtension( if (!data.error) { if (!silent) { + if (toastId) toast.dismiss(toastId); toast.success(`Successfully enabled ${extension.name} extension`); } return response; @@ -100,7 +104,9 @@ export async function addExtension( const errorMessage = `Error adding ${extension.name} extension ${data.message ? `. ${data.message}` : ''}`; console.error(errorMessage); - toast.error(errorMessage, { autoClose: false }); + if (toastId) toast.dismiss(toastId); + toast.error(errorMessage); + return response; } catch (error) { const errorMessage = `Failed to add ${extension.name} extension: ${error instanceof Error ? error.message : 'Unknown error'}`;