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) {
|
for (let i in this.allFiles) {
|
||||||
this.visibleFiles.push(i)
|
this.visibleFiles.push(i)
|
||||||
}
|
}
|
||||||
|
this.sortBy("")
|
||||||
this.renderVisibleFiles(true)
|
this.renderVisibleFiles(true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -107,7 +108,6 @@ DirectoryElement.prototype.search = function(term) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have to resort because we modified the visibleFiles array
|
|
||||||
this.sortBy("")
|
this.sortBy("")
|
||||||
this.renderVisibleFiles(true)
|
this.renderVisibleFiles(true)
|
||||||
}
|
}
|
||||||
|
@@ -10,9 +10,6 @@ function FileManager(windowElement) {
|
|||||||
this.btnReload = this.navBar.querySelector("#btn_reload")
|
this.btnReload = this.navBar.querySelector("#btn_reload")
|
||||||
this.inputSearch = this.navBar.querySelector("#input_search")
|
this.inputSearch = this.navBar.querySelector("#input_search")
|
||||||
|
|
||||||
// Buttons
|
|
||||||
this.btnReload.addEventListener("click", () => { this.getUserFiles() })
|
|
||||||
|
|
||||||
// Register keyboard shortcuts
|
// Register keyboard shortcuts
|
||||||
document.addEventListener("keydown", e => { this.keyboardEvent(e) })
|
document.addEventListener("keydown", e => { this.keyboardEvent(e) })
|
||||||
|
|
||||||
@@ -93,10 +90,9 @@ FileManager.prototype.getUserFiles = function() {
|
|||||||
|
|
||||||
FileManager.prototype.getUserLists = function() {
|
FileManager.prototype.getUserLists = function() {
|
||||||
this.setSpinner()
|
this.setSpinner()
|
||||||
|
this.directoryElement.reset()
|
||||||
|
|
||||||
let getAll = (page) => {
|
fetch(apiEndpoint+"/user/lists").then(resp => {
|
||||||
let numFiles = 1000
|
|
||||||
fetch(apiEndpoint+"/user/lists?page="+page+"&limit="+numFiles).then(resp => {
|
|
||||||
if (!resp.ok) { Promise.reject("yo") }
|
if (!resp.ok) { Promise.reject("yo") }
|
||||||
return resp.json()
|
return resp.json()
|
||||||
}).then(resp => {
|
}).then(resp => {
|
||||||
@@ -113,24 +109,13 @@ FileManager.prototype.getUserLists = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.directoryElement.renderFiles()
|
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()
|
this.delSpinner()
|
||||||
}
|
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
this.delSpinner()
|
this.delSpinner()
|
||||||
throw(err)
|
throw(err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.directoryElement.reset()
|
|
||||||
getAll(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
FileManager.prototype.keyboardEvent = function(e) {
|
FileManager.prototype.keyboardEvent = function(e) {
|
||||||
console.log("Pressed: "+e.keyCode)
|
console.log("Pressed: "+e.keyCode)
|
||||||
|
|
||||||
|
@@ -63,6 +63,7 @@
|
|||||||
|
|
||||||
hashChange()
|
hashChange()
|
||||||
|
|
||||||
|
document.getElementById("btn_reload").addEventListener("click", hashChange)
|
||||||
window.addEventListener("hashchange", hashChange)
|
window.addEventListener("hashchange", hashChange)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user