Disable button at end of infinite scrolling

This commit is contained in:
Eduard Urbach 2017-11-20 10:21:16 +01:00
parent 9fa9ccbe89
commit 8d7661cf9e

View File

@ -12,18 +12,19 @@ export function loadMore(arn: AnimeNotifier, button: HTMLButtonElement) {
let target = arn.app.find("load-more-target")
let index = button.dataset.index
fetch("/_" + arn.app.currentPath + "/from/" + index)
.then(response => {
let newIndex = response.headers.get("X-LoadMore-Index")
// End of data?
if(newIndex === "-1") {
button.disabled = true
button.classList.add("hidden")
} else {
button.dataset.index = newIndex
}
return response
})
.then(response => response.text())