proper nextpage implementation

This commit is contained in:
Bnyro 2022-11-01 12:39:01 +01:00
parent 40417bbdde
commit 94def0723d

View File

@ -139,6 +139,14 @@ export default {
if (this.loading || !this.channel || !this.channel.nextpage) return; if (this.loading || !this.channel || !this.channel.nextpage) return;
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) { if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
this.loading = true; this.loading = true;
if (this.selectedTab == 0) {
this.fetchChannelNextPage();
} else {
this.fetchChannelTabNextPage();
}
}
},
fetchChannelNextPage() {
this.fetchJson(this.apiUrl() + "/nextpage/channel/" + this.channel.id, { this.fetchJson(this.apiUrl() + "/nextpage/channel/" + this.channel.id, {
nextpage: this.channel.nextpage, nextpage: this.channel.nextpage,
}).then(json => { }).then(json => {
@ -147,7 +155,16 @@ export default {
this.updateWatched(json.relatedStreams); this.updateWatched(json.relatedStreams);
json.relatedStreams.map(stream => this.contentItems.push(stream)); json.relatedStreams.map(stream => this.contentItems.push(stream));
}); });
} },
fetchChannelTabNextPage() {
this.fetchJson(this.apiUrl() + "/channels/tabs", {
data: this.tabs[this.selectedTab].data,
nextpage: this.tabNextPage,
}).then(json => {
this.tabNextPage = json.nextpage;
this.loading = false;
json.content.map(item => this.contentItems.push(item));
});
}, },
subscribeHandler() { subscribeHandler() {
if (this.authenticated) { if (this.authenticated) {
@ -185,6 +202,7 @@ export default {
return translatedTabName; return translatedTabName;
}, },
loadTab(index) { loadTab(index) {
this.selectedTab = index;
if (index == 0) { if (index == 0) {
this.contentItems = this.channel.relatedStreams; this.contentItems = this.channel.relatedStreams;
return; return;