Workaround an http-only crash in Chrome, fix cancel on title screen

This commit is contained in:
LoveEevee 2021-06-01 12:21:55 +03:00
parent 657c631769
commit 3d09fea3a5

View File

@ -79,7 +79,8 @@ class CustomSongs{
this.selected = this.items.length - 1 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") this.dropzone = document.getElementById("dropzone")
var dropContent = this.dropzone.getElementsByClassName("view-content")[0] var dropContent = this.dropzone.getElementsByClassName("view-content")[0]
dropContent.innerText = strings.customSongs.dropzone dropContent.innerText = strings.customSongs.dropzone
@ -199,7 +200,7 @@ class CustomSongs{
for(var i = 0; i < event.dataTransfer.items.length; i++){ for(var i = 0; i < event.dataTransfer.items.length; i++){
var item = event.dataTransfer.items[i] var item = event.dataTransfer.items[i]
let promise let promise
if(item.getAsFileSystemHandle){ if(this.fileSystem){
promise = item.getAsFileSystemHandle().then(file => { promise = item.getAsFileSystemHandle().then(file => {
dbItems.push(file) dbItems.push(file)
return this.walkFilesystem(file) return this.walkFilesystem(file)
@ -245,7 +246,11 @@ class CustomSongs{
} }
importLocal(files){ importLocal(files){
if(!files.length){ if(!files.length){
return Promise.resolve("cancel") if(this.noPage){
return Promise.reject("cancel")
}else{
return Promise.resolve("cancel")
}
} }
this.locked = true this.locked = true
this.loading(true) this.loading(true)