fix sorting in file manager

This commit is contained in:
2020-08-09 20:24:40 +02:00
parent 588b829129
commit 096b26bc93
3 changed files with 25 additions and 39 deletions

View File

@@ -97,6 +97,7 @@ DirectoryElement.prototype.search = function(term) {
for (let i in this.allFiles) {
this.visibleFiles.push(i)
}
this.sortBy("")
this.renderVisibleFiles(true)
return
}
@@ -107,7 +108,6 @@ DirectoryElement.prototype.search = function(term) {
}
}
// We have to resort because we modified the visibleFiles array
this.sortBy("")
this.renderVisibleFiles(true)
}

View File

@@ -10,9 +10,6 @@ function FileManager(windowElement) {
this.btnReload = this.navBar.querySelector("#btn_reload")
this.inputSearch = this.navBar.querySelector("#input_search")
// Buttons
this.btnReload.addEventListener("click", () => { this.getUserFiles() })
// Register keyboard shortcuts
document.addEventListener("keydown", e => { this.keyboardEvent(e) })
@@ -93,10 +90,9 @@ FileManager.prototype.getUserFiles = function() {
FileManager.prototype.getUserLists = function() {
this.setSpinner()
this.directoryElement.reset()
let getAll = (page) => {
let numFiles = 1000
fetch(apiEndpoint+"/user/lists?page="+page+"&limit="+numFiles).then(resp => {
fetch(apiEndpoint+"/user/lists").then(resp => {
if (!resp.ok) { Promise.reject("yo") }
return resp.json()
}).then(resp => {
@@ -113,24 +109,13 @@ FileManager.prototype.getUserLists = function() {
}
this.directoryElement.renderFiles()
if (resp.lists.length === numFiles) {
getAll(page+1)
} else {
// Less than the maximum number of results means we're done
// loading, we can remove the loading spinner
this.delSpinner()
}
}).catch((err) => {
this.delSpinner()
throw(err)
})
}
this.directoryElement.reset()
getAll(0)
}
FileManager.prototype.keyboardEvent = function(e) {
console.log("Pressed: "+e.keyCode)

View File

@@ -63,6 +63,7 @@
hashChange()
document.getElementById("btn_reload").addEventListener("click", hashChange)
window.addEventListener("hashchange", hashChange)
})
</script>