From f590222568dcc98a827f268f3c641cb179b3149c Mon Sep 17 00:00:00 2001 From: LoveEevee Date: Thu, 29 Oct 2020 09:04:36 +0300 Subject: [PATCH] Fix metadata loading, loading animation, osu charts, and gpicker - Speed up metadata loading by not waiting for the audio - Make loading animation bigger on mobile - Fix osu charts imported with gdrive - Fix gpicker not appearing after cancelling --- public/src/css/loadsong.css | 10 +++++----- public/src/js/gpicker.js | 7 +++++-- public/src/js/songselect.js | 19 ++++++++++--------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/public/src/css/loadsong.css b/public/src/css/loadsong.css index 05ee398..f4e5489 100644 --- a/public/src/css/loadsong.css +++ b/public/src/css/loadsong.css @@ -13,8 +13,8 @@ flex-direction: column; justify-content: center; align-items: center; - width: 20vw; - height: 15vw; + width: 20vmax; + height: 15vmax; background: rgba(0, 0, 0, 0.75); border-radius: 5px; border: 3px solid white; @@ -22,14 +22,14 @@ z-index: 1; } #loading-don{ - width: 10vw; - height: calc(10vw / 120 * 115); + width: 10vmax; + height: calc(10vmax / 120 * 115); background-size: contain; background-repeat: no-repeat; } .loading-text{ position: relative; - font-size: 1.5vw; + font-size: 1.5vmax; text-align: center; z-index: 1; } diff --git a/public/src/js/gpicker.js b/public/src/js/gpicker.js index 0707b6c..bcd94af 100644 --- a/public/src/js/gpicker.js +++ b/public/src/js/gpicker.js @@ -21,6 +21,9 @@ class Gpicker{ for(var i = 0; i < files.length; i++){ var path = files[i].path ? files[i].path + "/" : "" var list = files[i].list + if(!list){ + continue + } for(var j = 0; j < list.length; j++){ var file = list[j] if(file.mimeType === this.folder){ @@ -68,7 +71,7 @@ class Gpicker{ } loadApi(){ if(window.gapi && gapi.client && gapi.client.drive){ - return + return Promise.resolve() } return loader.loadScript("https://apis.google.com/js/api.js") .then(() => new Promise((resolve, reject) => @@ -83,7 +86,7 @@ class Gpicker{ } getToken(lockedCallback){ if(this.oauthToken){ - return + return Promise.resolve() } if(!this.auth){ var authPromise = gapi.auth2.init({ diff --git a/public/src/js/songselect.js b/public/src/js/songselect.js index 64f6bfc..0e68284 100644 --- a/public/src/js/songselect.js +++ b/public/src/js/songselect.js @@ -2407,7 +2407,7 @@ class SongSelect{ return snd.previewGain.load(currentSong.music) }) }else if(currentSong.unloaded){ - var promise = this.getUnloaded(this.selectedSong, songObj) + var promise = this.getUnloaded(this.selectedSong, songObj, currentId) }else if(currentSong.sound){ songObj.preview_time = prvTime currentSong.sound.gain = snd.previewGain @@ -2468,13 +2468,13 @@ class SongSelect{ snd.musicGain.fadeOut(0.4) } } - getUnloaded(selectedSong, songObj){ + getUnloaded(selectedSong, songObj, currentId){ var currentSong = this.songs[selectedSong] var file = currentSong.chart var importSongs = new ImportSongs(false, assets.otherFiles) return file.read(currentSong.type === "tja" ? "sjis" : "").then(data => { currentSong.chart = new CachedFile(data, file) - return importSongs.addTja({ + return importSongs[currentSong.type === "tja" ? "addTja" : "addOsu"]({ file: currentSong.chart, index: 0 }) @@ -2485,14 +2485,15 @@ class SongSelect{ imported.order = currentSong.order delete imported.song_skin songObj.preview_time = imported.preview - if(imported.music){ + var index = assets.songs.findIndex(song => song.id === currentSong.id) + if(index !== -1){ + assets.songs[index] = imported + } + this.songs[selectedSong] = this.addSong(imported) + if(imported.music && currentId === this.previewId){ return snd.previewGain.load(imported.music).then(sound => { imported.sound = sound - var index = assets.songs.findIndex(song => song.id === currentSong.id) - if(index !== -1){ - assets.songs[index] = imported - } - this.songs[selectedSong] = this.addSong(imported) + this.songs[selectedSong].sound = sound return sound.copy() }) }else{