basic functionality

This commit is contained in:
Bnyro 2022-11-01 12:31:45 +01:00
parent 8006f3a199
commit 40417bbdde
2 changed files with 60 additions and 9 deletions

View file

@ -35,13 +35,19 @@
<font-awesome-icon icon="rss" /> <font-awesome-icon icon="rss" />
</a> </a>
<div class="flex mt-4 mb-2">
<button v-for="(tab, index) in tabs" :key="tab.name" class="btn mr-2" @click="loadTab(index)">
<span v-text="tab.translatedName"></span>
</button>
</div>
<hr /> <hr />
<div class="video-grid"> <div class="video-grid">
<VideoItem <ContentItem
v-for="video in channel.relatedStreams" v-for="item in contentItems"
:key="video.url" :key="item.url"
:video="video" :content-item="item"
height="94" height="94"
width="168" width="168"
hide-channel hide-channel
@ -52,17 +58,21 @@
<script> <script>
import ErrorHandler from "./ErrorHandler.vue"; import ErrorHandler from "./ErrorHandler.vue";
import VideoItem from "./VideoItem.vue"; import ContentItem from "./ContentItem.vue";
export default { export default {
components: { components: {
ErrorHandler, ErrorHandler,
VideoItem, ContentItem,
}, },
data() { data() {
return { return {
channel: null, channel: null,
subscribed: false, subscribed: false,
tabs: [],
selectedTab: 0,
contentItems: [],
tabNextPage: null,
}; };
}, },
mounted() { mounted() {
@ -111,8 +121,17 @@ export default {
.then(() => { .then(() => {
if (!this.channel.error) { if (!this.channel.error) {
document.title = this.channel.name + " - Piped"; document.title = this.channel.name + " - Piped";
this.contentItems = this.channel.relatedStreams;
this.fetchSubscribedStatus(); this.fetchSubscribedStatus();
this.updateWatched(this.channel.relatedStreams); this.updateWatched(this.channel.relatedStreams);
this.tabs.push({
translatedName: this.$t("video.videos"),
});
for (let i = 0; i < this.channel.tabs.length; i++) {
let tab = this.channel.tabs[i];
tab.translatedName = this.getTranslatedTabName(tab.name);
this.tabs.push(tab);
}
} }
}); });
}, },
@ -126,7 +145,7 @@ 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.channel.relatedStreams.push(stream)); json.relatedStreams.map(stream => this.contentItems.push(stream));
}); });
} }
}, },
@ -147,6 +166,36 @@ export default {
} }
this.subscribed = !this.subscribed; this.subscribed = !this.subscribed;
}, },
getTranslatedTabName(tabName) {
let translatedTabName = tabName;
switch (tabName) {
case "Livestreams":
translatedTabName = this.$t("titles.livestreams");
break;
case "Playlists":
translatedTabName = this.$t("titles.playlists");
break;
case "Channels":
translatedTabName = this.$t("titles.channels");
break;
case "Shorts":
translatedTabName = this.$t("video.shorts");
break;
}
return translatedTabName;
},
loadTab(index) {
if (index == 0) {
this.contentItems = this.channel.relatedStreams;
return;
}
this.fetchJson(this.apiUrl() + "/channels/tabs", {
data: this.tabs[index].data,
}).then(tab => {
this.contentItems = tab.content;
this.tabNextPage = tab.nextpage;
});
},
}, },
}; };
</script> </script>

View file

@ -10,7 +10,9 @@
"playlists": "Playlists", "playlists": "Playlists",
"account": "Account", "account": "Account",
"instance": "Instance", "instance": "Instance",
"player": "Player" "player": "Player",
"livestreams": "Livestreams",
"channels": "Channels"
}, },
"player": { "player": {
"watch_on": "Watch on {0}" "watch_on": "Watch on {0}"
@ -165,4 +167,4 @@
"copied": "Copied!", "copied": "Copied!",
"cannot_copy": "Can't copy!" "cannot_copy": "Can't copy!"
} }
} }