add "start export" button on format selection screen, clear all toasts after selecting an export format
This commit is contained in:
26
Il2CppInspector.Redux.GUI.UI/src/lib/export.svelte.ts
Normal file
26
Il2CppInspector.Redux.GUI.UI/src/lib/export.svelte.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { signalRState } from "./signalr/api.svelte";
|
||||||
|
|
||||||
|
class ExportState {
|
||||||
|
hasExportQueued = false;
|
||||||
|
|
||||||
|
async queueExport(
|
||||||
|
formatId: string,
|
||||||
|
outputDirectory: string,
|
||||||
|
options: Map<string, string>,
|
||||||
|
) {
|
||||||
|
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<ExportState>(new ExportState());
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
type DragDropEvent,
|
type DragDropEvent,
|
||||||
} from "@tauri-apps/api/webview";
|
} from "@tauri-apps/api/webview";
|
||||||
import type { UnlistenFn } from "@tauri-apps/api/event";
|
import type { UnlistenFn } from "@tauri-apps/api/event";
|
||||||
import { goto } from "$app/navigation";
|
|
||||||
import { open } from "@tauri-apps/plugin-dialog";
|
import { open } from "@tauri-apps/plugin-dialog";
|
||||||
|
|
||||||
async function chooseFile(event: Event) {
|
async function chooseFile(event: Event) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
buttonVariants,
|
buttonVariants,
|
||||||
} from "$lib/components/ui/button/button.svelte";
|
} from "$lib/components/ui/button/button.svelte";
|
||||||
import * as Tooltip from "$lib/components/ui/tooltip";
|
import * as Tooltip from "$lib/components/ui/tooltip";
|
||||||
|
import { exportState } from "$lib/export.svelte";
|
||||||
import { cn } from "$lib/utils";
|
import { cn } from "$lib/utils";
|
||||||
import type { PageProps } from "./$types";
|
import type { PageProps } from "./$types";
|
||||||
|
|
||||||
@@ -46,6 +47,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mx-5 mb-3 flex flex-row-reverse justify-between">
|
<div class="mx-5 mb-3 flex flex-row-reverse justify-between">
|
||||||
<Button href="/" variant="outline">Cancel</Button>
|
<Button href="/" variant="outline">Cancel</Button>
|
||||||
|
{#if exportState.hasExportQueued}
|
||||||
|
<Button onclick={() => exportState.startExport()} variant="default"
|
||||||
|
>Start export</Button
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
<Button href="/advanced" variant="ghost">Advanced</Button>
|
<Button href="/advanced" variant="ghost">Advanced</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,8 +8,9 @@
|
|||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import PathSelector from "$lib/components/settings/path-selector.svelte";
|
import PathSelector from "$lib/components/settings/path-selector.svelte";
|
||||||
import { open } from "@tauri-apps/plugin-dialog";
|
import { open } from "@tauri-apps/plugin-dialog";
|
||||||
import { signalRState } from "$lib/signalr/api.svelte";
|
|
||||||
import { toast } from "svelte-sonner";
|
import { toast } from "svelte-sonner";
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import { exportState } from "$lib/export.svelte";
|
||||||
|
|
||||||
let formatId = page.params.formatId;
|
let formatId = page.params.formatId;
|
||||||
let { data }: PageProps = $props();
|
let { data }: PageProps = $props();
|
||||||
@@ -115,14 +116,10 @@
|
|||||||
values.map((x) => [x.setting.name.id, x.selected.toString()]),
|
values.map((x) => [x.setting.name.id, x.selected.toString()]),
|
||||||
);
|
);
|
||||||
|
|
||||||
await signalRState.api?.server.queueExport(
|
await exportState.queueExport(formatId, exportDirectory, settings);
|
||||||
formatId,
|
|
||||||
exportDirectory,
|
|
||||||
settings,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (shouldStartExport) {
|
if (shouldStartExport) {
|
||||||
await signalRState.api?.server.startExport();
|
await exportState.startExport();
|
||||||
} else {
|
} else {
|
||||||
toast.info("Successfully queued export.");
|
toast.info("Successfully queued export.");
|
||||||
}
|
}
|
||||||
@@ -137,6 +134,11 @@
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
// we dismiss all toasts so that they don't block the export/queue buttons
|
||||||
|
toast.dismiss();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex w-screen flex-col">
|
<div class="flex w-screen flex-col">
|
||||||
|
|||||||
Reference in New Issue
Block a user