web/remux: check if env is browser before adding listeners

This commit is contained in:
wukko 2024-09-05 08:56:01 +06:00
parent 21832005e2
commit 80e32fc0c0
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2

View file

@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import mime from "mime"; import mime from "mime";
import LibAVWrapper from "$lib/libav"; import LibAVWrapper from "$lib/libav";
import { browser } from "$app/environment";
import { beforeNavigate } from '$app/navigation'; import { beforeNavigate } from '$app/navigation';
import { openURL } from "$lib/download"; import { openURL } from "$lib/download";
@ -151,9 +152,9 @@
} }
}) })
$: if (processing) { $: if (browser && processing) {
window.addEventListener("beforeunload", beforeUnloadHandler); window.addEventListener("beforeunload", beforeUnloadHandler);
} else { } else if (browser) {
window.removeEventListener("beforeunload", beforeUnloadHandler); window.removeEventListener("beforeunload", beforeUnloadHandler);
} }