mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Implement better handling of channel page loading.
This commit is contained in:
parent
00e7d22bdb
commit
649aad7a89
1 changed files with 16 additions and 5 deletions
|
@ -142,7 +142,13 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleScroll() {
|
handleScroll() {
|
||||||
if (this.loading || !this.channel || !this.channel.nextpage) return;
|
if (
|
||||||
|
this.loading ||
|
||||||
|
!this.channel ||
|
||||||
|
!this.channel.nextpage ||
|
||||||
|
(this.selectedTab != 0 && !this.tabs[this.selectedTab].tabNextPage)
|
||||||
|
)
|
||||||
|
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) {
|
if (this.selectedTab == 0) {
|
||||||
|
@ -165,11 +171,12 @@ export default {
|
||||||
fetchChannelTabNextPage() {
|
fetchChannelTabNextPage() {
|
||||||
this.fetchJson(this.apiUrl() + "/channels/tabs", {
|
this.fetchJson(this.apiUrl() + "/channels/tabs", {
|
||||||
data: this.tabs[this.selectedTab].data,
|
data: this.tabs[this.selectedTab].data,
|
||||||
nextpage: this.tabNextPage,
|
nextpage: this.tabs[this.selectedTab].tabNextPage,
|
||||||
}).then(json => {
|
}).then(json => {
|
||||||
this.tabNextPage = json.nextpage;
|
this.tabs[this.selectedTab].tabNextPage = json.nextpage;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
json.content.map(item => this.contentItems.push(item));
|
json.content.map(item => this.contentItems.push(item));
|
||||||
|
this.tabs[this.selectedTab].content = this.contentItems;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
subscribeHandler() {
|
subscribeHandler() {
|
||||||
|
@ -216,11 +223,15 @@ export default {
|
||||||
this.contentItems = this.channel.relatedStreams;
|
this.contentItems = this.channel.relatedStreams;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this.tabs[index].content) {
|
||||||
|
this.contentItems = this.tabs[index].content;
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.fetchJson(this.apiUrl() + "/channels/tabs", {
|
this.fetchJson(this.apiUrl() + "/channels/tabs", {
|
||||||
data: this.tabs[index].data,
|
data: this.tabs[index].data,
|
||||||
}).then(tab => {
|
}).then(tab => {
|
||||||
this.contentItems = tab.content;
|
this.contentItems = this.tabs[index].content = tab.content;
|
||||||
this.tabNextPage = tab.nextpage;
|
this.tabs[this.selectedTab].tabNextPage = tab.nextpage;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue