add "start export" button on format selection screen, clear all toasts after selecting an export format

This commit is contained in:
LukeFZ
2025-04-20 16:26:01 +02:00
parent 6659e0893b
commit 1163ed597c
4 changed files with 41 additions and 8 deletions

View 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());

View File

@@ -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) {

View File

@@ -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 @@
</div>
<div class="mx-5 mb-3 flex flex-row-reverse justify-between">
<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>
</div>
</div>

View File

@@ -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();
});
</script>
<div class="flex w-screen flex-col">