From b5b8b5abf8c09b35fa35c63c8c10ad31670fe692 Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Wed, 31 Mar 2021 10:21:41 +0200 Subject: [PATCH] :bug: Fix browser compatibility --- src/views/Loader.svelte | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/views/Loader.svelte b/src/views/Loader.svelte index 439d22b..801c8e1 100644 --- a/src/views/Loader.svelte +++ b/src/views/Loader.svelte @@ -16,6 +16,12 @@ const files = []; uz.onfile = (f) => files.push(f); + if (!file.stream) { + loading = false; + error = 'This browser is not supported. Try using Google Chrome instead.'; + return; + } + const reader = file.stream().getReader(); while (true) { const { done, value } = await reader.read(); @@ -30,7 +36,7 @@ const validPackage = files.some((file) => file.name === 'README.txt'); if (!validPackage) { - error = true; + error = 'Your package seems to be corrupted. Click or drop your package file here to retry'; loading = false; return; } @@ -42,7 +48,7 @@ loadTask.set(null); console.log(`[debug] Data extracted in ${(Date.now() - extractStartAt) / 1000} seconds.`); }).catch((err) => { - error = true; + error = 'Something went wrong... Click or drop your package file here to retry'; loading = false; alert(err.stack); }); @@ -78,7 +84,7 @@ {/if} {:else if error} -

Something went wrong... Click or drop your package file here to retry

+

{error}

{:else}

Click or drop your package file here

{/if}