From a61d6eabe176b3154eb23ef6cd085914b86a8a49 Mon Sep 17 00:00:00 2001 From: Luis Felipe Santos do Nascimento Date: Sat, 5 Jun 2021 04:45:06 -0300 Subject: [PATCH] :bug: Fix infinite loading on drop file (#30) --- README.md | 2 ++ src/views/Loader.svelte | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b64355..f2bf39d 100644 --- a/README.md +++ b/README.md @@ -23,3 +23,5 @@ Discord Data Package Explorer is built with **[Svelte](https://svelte.dev)**, an * Clone the repository. * Install the dependencies using `npm install` or `yarn install`. * Start the app using `npm run dev` or `yarn dev`! + +> Note: for testing purposes, you may append `?demo` to the URL to use the mocked data. diff --git a/src/views/Loader.svelte b/src/views/Loader.svelte index 2c6c2f7..e918ebd 100644 --- a/src/views/Loader.svelte +++ b/src/views/Loader.svelte @@ -67,9 +67,15 @@ event.preventDefault(); } + /** @see https://developer.mozilla.org/en-US/docs/Web/API/Document/drop_event */ function handleDrop (event) { event.preventDefault(); - handleFile(event.dataTransfer.items[0].getAsFile()); + + if (event.dataTransfer.items[0].getAsFile() !== null) { + handleFile(event.dataTransfer.items[0].getAsFile()); + } else { + error = 'Error trying to handle the dropped file. Try clicking instead.'; + } } function filePopup (event) {