mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2024-08-14 23:57:27 +00:00 
			
		
		
		
	Merge pull request #3674 from Bnyro/master
fix: race conditions when when loading lots of videos quickly
This commit is contained in:
		
						commit
						0a95270461
					
				
					 5 changed files with 11 additions and 13 deletions
				
			
		| 
						 | 
					@ -183,8 +183,8 @@ export default {
 | 
				
			||||||
                this.channel.nextpage = json.nextpage;
 | 
					                this.channel.nextpage = json.nextpage;
 | 
				
			||||||
                this.loading = false;
 | 
					                this.loading = false;
 | 
				
			||||||
                this.updateWatched(json.relatedStreams);
 | 
					                this.updateWatched(json.relatedStreams);
 | 
				
			||||||
                json.relatedStreams.map(stream => this.contentItems.push(stream));
 | 
					                this.contentItems.push(...json.relatedStreams);
 | 
				
			||||||
                this.fetchDeArrowContent(this.contentItems);
 | 
					                this.fetchDeArrowContent(json.relatedStreams);
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        fetchChannelTabNextPage() {
 | 
					        fetchChannelTabNextPage() {
 | 
				
			||||||
| 
						 | 
					@ -194,8 +194,8 @@ export default {
 | 
				
			||||||
            }).then(json => {
 | 
					            }).then(json => {
 | 
				
			||||||
                this.tabs[this.selectedTab].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.this.contentItems.push(...json.content);
 | 
				
			||||||
                this.fetchDeArrowContent(this.contentItems);
 | 
					                this.fetchDeArrowContent(json.content);
 | 
				
			||||||
                this.tabs[this.selectedTab].content = this.contentItems;
 | 
					                this.tabs[this.selectedTab].content = this.contentItems;
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
| 
						 | 
					@ -246,7 +246,7 @@ export default {
 | 
				
			||||||
                data: this.tabs[index].data,
 | 
					                data: this.tabs[index].data,
 | 
				
			||||||
            }).then(tab => {
 | 
					            }).then(tab => {
 | 
				
			||||||
                this.contentItems = this.tabs[index].content = tab.content;
 | 
					                this.contentItems = this.tabs[index].content = tab.content;
 | 
				
			||||||
                this.fetchDeArrowContent(this.contentItems);
 | 
					                this.fetchDeArrowContent(tab.content);
 | 
				
			||||||
                this.tabs[this.selectedTab].tabNextPage = tab.nextpage;
 | 
					                this.tabs[this.selectedTab].tabNextPage = tab.nextpage;
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
<template v-if="text">
 | 
					<template>
 | 
				
			||||||
    <div class="mx-1 whitespace-pre-wrap py-2">
 | 
					    <div v-if="text" class="mx-1 whitespace-pre-wrap py-2">
 | 
				
			||||||
        <!-- eslint-disable-next-line vue/no-v-html -->
 | 
					        <!-- eslint-disable-next-line vue/no-v-html -->
 | 
				
			||||||
        <span v-if="showFullText" class="contentText" v-html="fullText()" />
 | 
					        <span v-if="showFullText" class="contentText" v-html="fullText()" />
 | 
				
			||||||
        <!-- eslint-disable-next-line vue/no-v-html -->
 | 
					        <!-- eslint-disable-next-line vue/no-v-html -->
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -131,8 +131,8 @@ export default {
 | 
				
			||||||
            if (!this.videosStore) return;
 | 
					            if (!this.videosStore) return;
 | 
				
			||||||
            this.currentVideoCount = Math.min(this.currentVideoCount + this.videoStep, this.videosStore.length);
 | 
					            this.currentVideoCount = Math.min(this.currentVideoCount + this.videoStep, this.videosStore.length);
 | 
				
			||||||
            if (this.videos.length != this.videosStore.length) {
 | 
					            if (this.videos.length != this.videosStore.length) {
 | 
				
			||||||
 | 
					                this.fetchDeArrowContent(this.videosStore.slice(this.videos.length, this.currentVideoCount));
 | 
				
			||||||
                this.videos = this.videosStore.slice(0, this.currentVideoCount);
 | 
					                this.videos = this.videosStore.slice(0, this.currentVideoCount);
 | 
				
			||||||
                this.fetchDeArrowContent(this.videos);
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        handleScroll() {
 | 
					        handleScroll() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -525,9 +525,7 @@ export default {
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
                await this.fetchPlaylistPages().then(() => {
 | 
					                await this.fetchPlaylistPages();
 | 
				
			||||||
                    this.fetchDeArrowContent(this.playlist.relatedStreams);
 | 
					 | 
				
			||||||
                });
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        async fetchPlaylistPages() {
 | 
					        async fetchPlaylistPages() {
 | 
				
			||||||
| 
						 | 
					@ -535,8 +533,9 @@ export default {
 | 
				
			||||||
                await this.fetchJson(this.apiUrl() + "/nextpage/playlists/" + this.playlistId, {
 | 
					                await this.fetchJson(this.apiUrl() + "/nextpage/playlists/" + this.playlistId, {
 | 
				
			||||||
                    nextpage: this.playlist.nextpage,
 | 
					                    nextpage: this.playlist.nextpage,
 | 
				
			||||||
                }).then(json => {
 | 
					                }).then(json => {
 | 
				
			||||||
                    this.playlist.relatedStreams = this.playlist.relatedStreams.concat(json.relatedStreams);
 | 
					                    this.playlist.relatedStreams.push(...json.relatedStreams);
 | 
				
			||||||
                    this.playlist.nextpage = json.nextpage;
 | 
					                    this.playlist.nextpage = json.nextpage;
 | 
				
			||||||
 | 
					                    this.fetchDeArrowContent(json.relatedStreams);
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
                await this.fetchPlaylistPages();
 | 
					                await this.fetchPlaylistPages();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -524,7 +524,6 @@ const mixin = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            const videoIds = content
 | 
					            const videoIds = content
 | 
				
			||||||
                .filter(item => item.type === "stream")
 | 
					                .filter(item => item.type === "stream")
 | 
				
			||||||
                .filter(item => item.dearrow === undefined)
 | 
					 | 
				
			||||||
                .map(item => item.url.substr(-11))
 | 
					                .map(item => item.url.substr(-11))
 | 
				
			||||||
                .sort();
 | 
					                .sort();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue