diff --git a/Il2CppInspector.Redux.GUI.UI/src/lib/export.svelte.ts b/Il2CppInspector.Redux.GUI.UI/src/lib/export.svelte.ts new file mode 100644 index 0000000..adce14c --- /dev/null +++ b/Il2CppInspector.Redux.GUI.UI/src/lib/export.svelte.ts @@ -0,0 +1,26 @@ +import { signalRState } from "./signalr/api.svelte"; + +class ExportState { + hasExportQueued = false; + + async queueExport( + formatId: string, + outputDirectory: string, + options: Map, + ) { + await signalRState.api?.server.queueExport( + formatId, + outputDirectory, + options, + ); + + this.hasExportQueued = true; + } + + async startExport() { + await signalRState.api?.server.startExport(); + this.hasExportQueued = false; + } +} + +export const exportState = $state(new ExportState()); diff --git a/Il2CppInspector.Redux.GUI.UI/src/routes/+page.svelte b/Il2CppInspector.Redux.GUI.UI/src/routes/+page.svelte index 31f601c..d779f48 100644 --- a/Il2CppInspector.Redux.GUI.UI/src/routes/+page.svelte +++ b/Il2CppInspector.Redux.GUI.UI/src/routes/+page.svelte @@ -8,7 +8,6 @@ type DragDropEvent, } from "@tauri-apps/api/webview"; import type { UnlistenFn } from "@tauri-apps/api/event"; - import { goto } from "$app/navigation"; import { open } from "@tauri-apps/plugin-dialog"; async function chooseFile(event: Event) { diff --git a/Il2CppInspector.Redux.GUI.UI/src/routes/export/+page.svelte b/Il2CppInspector.Redux.GUI.UI/src/routes/export/+page.svelte index 9a00384..c9d6d23 100644 --- a/Il2CppInspector.Redux.GUI.UI/src/routes/export/+page.svelte +++ b/Il2CppInspector.Redux.GUI.UI/src/routes/export/+page.svelte @@ -4,6 +4,7 @@ buttonVariants, } from "$lib/components/ui/button/button.svelte"; import * as Tooltip from "$lib/components/ui/tooltip"; + import { exportState } from "$lib/export.svelte"; import { cn } from "$lib/utils"; import type { PageProps } from "./$types"; @@ -46,6 +47,11 @@
+ {#if exportState.hasExportQueued} + + {/if}
diff --git a/Il2CppInspector.Redux.GUI.UI/src/routes/export/[formatId]/+page.svelte b/Il2CppInspector.Redux.GUI.UI/src/routes/export/[formatId]/+page.svelte index 87b557d..2f3ac6b 100644 --- a/Il2CppInspector.Redux.GUI.UI/src/routes/export/[formatId]/+page.svelte +++ b/Il2CppInspector.Redux.GUI.UI/src/routes/export/[formatId]/+page.svelte @@ -8,8 +8,9 @@ import { goto } from "$app/navigation"; import PathSelector from "$lib/components/settings/path-selector.svelte"; import { open } from "@tauri-apps/plugin-dialog"; - import { signalRState } from "$lib/signalr/api.svelte"; import { toast } from "svelte-sonner"; + import { onMount } from "svelte"; + import { exportState } from "$lib/export.svelte"; let formatId = page.params.formatId; let { data }: PageProps = $props(); @@ -115,14 +116,10 @@ values.map((x) => [x.setting.name.id, x.selected.toString()]), ); - await signalRState.api?.server.queueExport( - formatId, - exportDirectory, - settings, - ); + await exportState.queueExport(formatId, exportDirectory, settings); if (shouldStartExport) { - await signalRState.api?.server.startExport(); + await exportState.startExport(); } else { toast.info("Successfully queued export."); } @@ -137,6 +134,11 @@ return true; }); + + onMount(() => { + // we dismiss all toasts so that they don't block the export/queue buttons + toast.dismiss(); + });