Disable button at end of infinite scrolling
This commit is contained in:
@ -12,18 +12,19 @@ export function loadMore(arn: AnimeNotifier, button: HTMLButtonElement) {
|
|||||||
|
|
||||||
let target = arn.app.find("load-more-target")
|
let target = arn.app.find("load-more-target")
|
||||||
let index = button.dataset.index
|
let index = button.dataset.index
|
||||||
|
|
||||||
fetch("/_" + arn.app.currentPath + "/from/" + index)
|
fetch("/_" + arn.app.currentPath + "/from/" + index)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
let newIndex = response.headers.get("X-LoadMore-Index")
|
let newIndex = response.headers.get("X-LoadMore-Index")
|
||||||
|
|
||||||
// End of data?
|
// End of data?
|
||||||
if(newIndex === "-1") {
|
if(newIndex === "-1") {
|
||||||
|
button.disabled = true
|
||||||
button.classList.add("hidden")
|
button.classList.add("hidden")
|
||||||
} else {
|
} else {
|
||||||
button.dataset.index = newIndex
|
button.dataset.index = newIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
return response
|
return response
|
||||||
})
|
})
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
|
Reference in New Issue
Block a user