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
This commit is contained in:
LoveEevee 2020-10-29 09:04:36 +03:00
parent 3fea149353
commit f590222568
3 changed files with 20 additions and 16 deletions

View File

@ -13,8 +13,8 @@
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
width: 20vw; width: 20vmax;
height: 15vw; height: 15vmax;
background: rgba(0, 0, 0, 0.75); background: rgba(0, 0, 0, 0.75);
border-radius: 5px; border-radius: 5px;
border: 3px solid white; border: 3px solid white;
@ -22,14 +22,14 @@
z-index: 1; z-index: 1;
} }
#loading-don{ #loading-don{
width: 10vw; width: 10vmax;
height: calc(10vw / 120 * 115); height: calc(10vmax / 120 * 115);
background-size: contain; background-size: contain;
background-repeat: no-repeat; background-repeat: no-repeat;
} }
.loading-text{ .loading-text{
position: relative; position: relative;
font-size: 1.5vw; font-size: 1.5vmax;
text-align: center; text-align: center;
z-index: 1; z-index: 1;
} }

View File

@ -21,6 +21,9 @@ class Gpicker{
for(var i = 0; i < files.length; i++){ for(var i = 0; i < files.length; i++){
var path = files[i].path ? files[i].path + "/" : "" var path = files[i].path ? files[i].path + "/" : ""
var list = files[i].list var list = files[i].list
if(!list){
continue
}
for(var j = 0; j < list.length; j++){ for(var j = 0; j < list.length; j++){
var file = list[j] var file = list[j]
if(file.mimeType === this.folder){ if(file.mimeType === this.folder){
@ -68,7 +71,7 @@ class Gpicker{
} }
loadApi(){ loadApi(){
if(window.gapi && gapi.client && gapi.client.drive){ if(window.gapi && gapi.client && gapi.client.drive){
return return Promise.resolve()
} }
return loader.loadScript("https://apis.google.com/js/api.js") return loader.loadScript("https://apis.google.com/js/api.js")
.then(() => new Promise((resolve, reject) => .then(() => new Promise((resolve, reject) =>
@ -83,7 +86,7 @@ class Gpicker{
} }
getToken(lockedCallback){ getToken(lockedCallback){
if(this.oauthToken){ if(this.oauthToken){
return return Promise.resolve()
} }
if(!this.auth){ if(!this.auth){
var authPromise = gapi.auth2.init({ var authPromise = gapi.auth2.init({

View File

@ -2407,7 +2407,7 @@ class SongSelect{
return snd.previewGain.load(currentSong.music) return snd.previewGain.load(currentSong.music)
}) })
}else if(currentSong.unloaded){ }else if(currentSong.unloaded){
var promise = this.getUnloaded(this.selectedSong, songObj) var promise = this.getUnloaded(this.selectedSong, songObj, currentId)
}else if(currentSong.sound){ }else if(currentSong.sound){
songObj.preview_time = prvTime songObj.preview_time = prvTime
currentSong.sound.gain = snd.previewGain currentSong.sound.gain = snd.previewGain
@ -2468,13 +2468,13 @@ class SongSelect{
snd.musicGain.fadeOut(0.4) snd.musicGain.fadeOut(0.4)
} }
} }
getUnloaded(selectedSong, songObj){ getUnloaded(selectedSong, songObj, currentId){
var currentSong = this.songs[selectedSong] var currentSong = this.songs[selectedSong]
var file = currentSong.chart var file = currentSong.chart
var importSongs = new ImportSongs(false, assets.otherFiles) var importSongs = new ImportSongs(false, assets.otherFiles)
return file.read(currentSong.type === "tja" ? "sjis" : "").then(data => { return file.read(currentSong.type === "tja" ? "sjis" : "").then(data => {
currentSong.chart = new CachedFile(data, file) currentSong.chart = new CachedFile(data, file)
return importSongs.addTja({ return importSongs[currentSong.type === "tja" ? "addTja" : "addOsu"]({
file: currentSong.chart, file: currentSong.chart,
index: 0 index: 0
}) })
@ -2485,14 +2485,15 @@ class SongSelect{
imported.order = currentSong.order imported.order = currentSong.order
delete imported.song_skin delete imported.song_skin
songObj.preview_time = imported.preview 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 => { return snd.previewGain.load(imported.music).then(sound => {
imported.sound = sound imported.sound = sound
var index = assets.songs.findIndex(song => song.id === currentSong.id) this.songs[selectedSong].sound = sound
if(index !== -1){
assets.songs[index] = imported
}
this.songs[selectedSong] = this.addSong(imported)
return sound.copy() return sound.copy()
}) })
}else{ }else{