From 7f72485a0449f7b5db829d6ad6b4abbd059fe36b Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 26 Jan 2023 19:43:07 +0100 Subject: [PATCH] Save the tab param to the URL at runtime --- src/components/ChannelPage.vue | 3 +++ src/main.js | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/components/ChannelPage.vue b/src/components/ChannelPage.vue index 458963fa..4bce5531 100644 --- a/src/components/ChannelPage.vue +++ b/src/components/ChannelPage.vue @@ -224,10 +224,13 @@ export default { }, loadTab(index) { this.selectedTab = index; + this.appendQueryToUrl("tab", this.tabs[index].name ?? "videos"); + if (index == 0) { this.contentItems = this.channel.relatedStreams; return; } + if (this.tabs[index].content) { this.contentItems = this.tabs[index].content; return; diff --git a/src/main.js b/src/main.js index 12cf63ef..67538926 100644 --- a/src/main.js +++ b/src/main.js @@ -251,6 +251,18 @@ const mixin = { elem.click(); elem.remove(); }, + appendQueryToUrl(key, value) { + let searchParams = new URLSearchParams(window.location.search); + searchParams.set(key, value); + let newurl = + window.location.protocol + + "//" + + window.location.host + + window.location.pathname + + "?" + + searchParams.toString(); + window.history.pushState({ path: newurl }, "", newurl); + }, }, computed: { authenticated(_this) {