Skip to content

best way to save what you love

web/dialog: refactor types and logic

dumbmoron7c5b703e373b
diff --git a/web/src/components/dialog/DialogHolder.svelte b/web/src/components/dialog/DialogHolder.svelte
index 61503fcd..a77607c3 100644
--- a/web/src/components/dialog/DialogHolder.svelte
+++ b/web/src/components/dialog/DialogHolder.svelte
@@ -19,9 +19,7 @@
bodySubText={dialog.bodySubText}
buttons={dialog.buttons}
/>
- {/if}
-
- {#if dialog.type === "picker"}
+ {:else if dialog.type === "picker"}
<PickerDialog
id={dialog.id}
items={dialog.items}
diff --git a/web/src/components/save/buttons/DownloadButton.svelte b/web/src/components/save/buttons/DownloadButton.svelte
index fe5f26a0..7383d23a 100644
--- a/web/src/components/save/buttons/DownloadButton.svelte
+++ b/web/src/components/save/buttons/DownloadButton.svelte
@@ -69,7 +69,7 @@
restoreDownloadButton();
return createDialog({
- ...(defaultErrorPopup as DialogInfo),
+ ...defaultErrorPopup,
bodyText: "couldn't access the api",
});
}
@@ -79,7 +79,7 @@
restoreDownloadButton();
return createDialog({
- ...(defaultErrorPopup as DialogInfo),
+ ...defaultErrorPopup,
bodyText: response.text,
});
}
@@ -106,7 +106,7 @@
restoreDownloadButton();
return createDialog({
- ...(defaultErrorPopup as DialogInfo),
+ ...defaultErrorPopup,
bodyText: "couldn't probe the stream",
});
}
@@ -146,7 +146,7 @@
restoreDownloadButton();
return createDialog({
- ...(defaultErrorPopup as DialogInfo),
+ ...defaultErrorPopup,
bodyText: "unknown/unsupported status",
});
};
diff --git a/web/src/lib/types/dialog.ts b/web/src/lib/types/dialog.ts
index f6d2439d..2775cdc1 100644
--- a/web/src/lib/types/dialog.ts
+++ b/web/src/lib/types/dialog.ts
@@ -15,14 +15,23 @@ export type DialogPickerItem = {
thumb?: string,
}
-export type DialogInfo = {
+type Dialog = {
id: string,
- type: "small" | "picker",
+ buttons?: DialogButton[],
+};
+
+export type SmallDialog = Dialog & {
+ type: "small",
meowbalt?: MeowbaltEmotions,
icon?: SmallDialogIcons,
title?: string,
bodyText?: string,
bodySubText?: string,
- buttons?: DialogButton[],
+};
+
+export type PickerDialog = Dialog & {
+ type: "picker",
items?: DialogPickerItem[],
-}
+};
+
+export type DialogInfo = SmallDialog | PickerDialog;
\ No newline at end of file