mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2025-11-03 22:21:55 +00:00 
			
		
		
		
	Merge pull request #2022 from Bnyro/channel-tabs-query
Allow channel tabs as query parameter
This commit is contained in:
		@@ -136,10 +136,12 @@ export default {
 | 
				
			|||||||
                        this.tabs.push({
 | 
					                        this.tabs.push({
 | 
				
			||||||
                            translatedName: this.$t("video.videos"),
 | 
					                            translatedName: this.$t("video.videos"),
 | 
				
			||||||
                        });
 | 
					                        });
 | 
				
			||||||
 | 
					                        const tabQuery = this.$route.query.tab;
 | 
				
			||||||
                        for (let i = 0; i < this.channel.tabs.length; i++) {
 | 
					                        for (let i = 0; i < this.channel.tabs.length; i++) {
 | 
				
			||||||
                            let tab = this.channel.tabs[i];
 | 
					                            let tab = this.channel.tabs[i];
 | 
				
			||||||
                            tab.translatedName = this.getTranslatedTabName(tab.name);
 | 
					                            tab.translatedName = this.getTranslatedTabName(tab.name);
 | 
				
			||||||
                            this.tabs.push(tab);
 | 
					                            this.tabs.push(tab);
 | 
				
			||||||
 | 
					                            if (tab.name === tabQuery) this.loadTab(i + 1);
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
@@ -222,10 +224,17 @@ export default {
 | 
				
			|||||||
        },
 | 
					        },
 | 
				
			||||||
        loadTab(index) {
 | 
					        loadTab(index) {
 | 
				
			||||||
            this.selectedTab = index;
 | 
					            this.selectedTab = index;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // update the tab query in the url path
 | 
				
			||||||
 | 
					            const url = new URL(window.location);
 | 
				
			||||||
 | 
					            url.searchParams.set("tab", this.tabs[index].name ?? "videos");
 | 
				
			||||||
 | 
					            window.history.replaceState(window.history.state, "", url);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (index == 0) {
 | 
					            if (index == 0) {
 | 
				
			||||||
                this.contentItems = this.channel.relatedStreams;
 | 
					                this.contentItems = this.channel.relatedStreams;
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (this.tabs[index].content) {
 | 
					            if (this.tabs[index].content) {
 | 
				
			||||||
                this.contentItems = this.tabs[index].content;
 | 
					                this.contentItems = this.tabs[index].content;
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user