From 3d09fea3a5644b9e033fa4ddacfaba891f3a7da5 Mon Sep 17 00:00:00 2001 From: LoveEevee Date: Tue, 1 Jun 2021 12:21:55 +0300 Subject: [PATCH] Workaround an http-only crash in Chrome, fix cancel on title screen --- public/src/js/customsongs.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/public/src/js/customsongs.js b/public/src/js/customsongs.js index 2a7a5a6..34ae66e 100644 --- a/public/src/js/customsongs.js +++ b/public/src/js/customsongs.js @@ -79,7 +79,8 @@ class CustomSongs{ this.selected = this.items.length - 1 } - if(DataTransferItem.prototype.getAsFileSystemHandle || DataTransferItem.prototype.webkitGetAsEntry){ + this.fileSystem = location.protocol === "https:" && DataTransferItem.prototype.getAsFileSystemHandle + if(this.fileSystem || DataTransferItem.prototype.webkitGetAsEntry){ this.dropzone = document.getElementById("dropzone") var dropContent = this.dropzone.getElementsByClassName("view-content")[0] dropContent.innerText = strings.customSongs.dropzone @@ -199,7 +200,7 @@ class CustomSongs{ for(var i = 0; i < event.dataTransfer.items.length; i++){ var item = event.dataTransfer.items[i] let promise - if(item.getAsFileSystemHandle){ + if(this.fileSystem){ promise = item.getAsFileSystemHandle().then(file => { dbItems.push(file) return this.walkFilesystem(file) @@ -245,7 +246,11 @@ class CustomSongs{ } importLocal(files){ if(!files.length){ - return Promise.resolve("cancel") + if(this.noPage){ + return Promise.reject("cancel") + }else{ + return Promise.resolve("cancel") + } } this.locked = true this.loading(true)