From 6c4c5fd4f288b98b87c7589b124babef469ff1f5 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Tue, 3 Sep 2024 18:44:43 +0000 Subject: [PATCH] web/libav: move pre-init to onMount --- web/src/routes/remux/+page.svelte | 10 +++------- web/src/routes/shrink/+page.svelte | 7 ++----- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/web/src/routes/remux/+page.svelte b/web/src/routes/remux/+page.svelte index fd223847..6f9d075d 100644 --- a/web/src/routes/remux/+page.svelte +++ b/web/src/routes/remux/+page.svelte @@ -2,13 +2,12 @@ import mime from "mime"; import LibAVWrapper from "$lib/libav/remux"; - import { onDestroy } from "svelte"; + import { onDestroy, onMount } from "svelte"; import { beforeNavigate, goto } from "$app/navigation"; import { t } from "$lib/i18n/translations"; import { createDialog } from "$lib/dialogs"; import { downloadFile } from "$lib/download"; - import { browser } from "$app/environment"; import Skeleton from "$components/misc/Skeleton.svelte"; import DropReceiver from "$components/misc/DropReceiver.svelte"; @@ -53,13 +52,9 @@ } }); - if (browser) { - ff.init(); - } - const render = async () => { if (!file || processing) return; - await ff.init(); + ff.init(); let dialogOpened; try { @@ -199,6 +194,7 @@ render(); } + onMount(() => ff.init()); onDestroy(() => ff.terminate()); diff --git a/web/src/routes/shrink/+page.svelte b/web/src/routes/shrink/+page.svelte index 5ed40d8a..67e4de2e 100644 --- a/web/src/routes/shrink/+page.svelte +++ b/web/src/routes/shrink/+page.svelte @@ -7,16 +7,12 @@ import DropReceiver from "$components/misc/DropReceiver.svelte"; import FileReceiver from "$components/misc/FileReceiver.svelte"; import type { StreamInfo } from "$lib/types/libav"; - import { onDestroy } from "svelte"; + import { onDestroy, onMount } from "svelte"; let file: File | undefined; let streamInfo: StreamInfo[] | undefined; const ff = new LibAVWrapper(); - if (browser) { - ff.init(); - } - const render = async () => { if (!file) return; await ff.init(); @@ -58,6 +54,7 @@ pseudolink.click(); }; + onMount(() => ff.init()); onDestroy(async () => { if (browser) { await ff.cleanup();