fix sorting in file manager
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
@@ -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,22 +109,11 @@ 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) {
|
||||
|
@@ -63,6 +63,7 @@
|
||||
|
||||
hashChange()
|
||||
|
||||
document.getElementById("btn_reload").addEventListener("click", hashChange)
|
||||
window.addEventListener("hashchange", hashChange)
|
||||
})
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user