0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-29 14:43:04 +00:00

channel global state setup

This commit is contained in:
Nikita Krupin 2022-05-14 00:16:15 -04:00
parent b6eb64ebf6
commit 20a7641119
5 changed files with 76 additions and 57 deletions

View file

@ -2,14 +2,14 @@
<div class="d-flex flex-column align-center"> <div class="d-flex flex-column align-center">
<v-img <v-img
height="120" height="120"
:src="banner" :src="$store.state.channel.banner"
class="background" class="background"
:class="$vuetify.theme.dark ? 'lighten-1' : 'darken-1'" :class="$vuetify.theme.dark ? 'lighten-1' : 'darken-1'"
></v-img> ></v-img>
<v-avatar size="60" class="mt-2 primary"> <v-avatar size="60" class="mt-2 primary">
<img :src="avatar" /> <img :src="$store.state.channel.avatar" />
</v-avatar> </v-avatar>
<h2 class="mt-2">{{ title }}</h2> <h2 class="mt-2">{{ $store.state.channel.title }}</h2>
<v-btn <v-btn
:aria-label="subscribeAlt" :aria-label="subscribeAlt"
class="mt-2" class="mt-2"
@ -17,67 +17,31 @@
color="primary" color="primary"
style="height: 1rem" style="height: 1rem"
> >
{{ subscribe }} {{ $store.state.channel.subscribe }}
</v-btn> </v-btn>
<div style="font-size: 0.75rem" class="mt-2"> <div style="font-size: 0.75rem" class="mt-2">
{{ subscribers }} &middot; {{ videos }} {{ $store.state.channel.subscribers }} &middot;
{{ $store.state.channel.videos }}
</div> </div>
<div <v-card
style="font-size: 0.75rem" flat
class="background--text text-center px-4" to="/channel/about?text=AboutDescription"
style="
font-size: 0.75rem;
height: 2rem;
text-oveflow: ellipsis;
overflow: hidden;
"
class="background background--text text-center px-4"
:class="$vuetify.theme.dark ? 'text--lighten-4' : 'text--darken-4'" :class="$vuetify.theme.dark ? 'text--lighten-4' : 'text--darken-4'"
> >
{{ descriptionPreview }} {{ $store.state.channel.descriptionPreview }}
<v-icon <v-icon
class="background--text" class="background--text"
:class="$vuetify.theme.dark ? 'text--lighten-4' : 'text--darken-4'" :class="$vuetify.theme.dark ? 'text--lighten-4' : 'text--darken-4'"
> >
mdi-chevron-right mdi-chevron-right
</v-icon> </v-icon>
</div> </v-card>
</div> </div>
</template> </template>
<script>
export default {
data: () => ({
channel: null,
avatar: null,
banner: null,
title: null,
subscribe: null,
subscribeAlt: null,
descriptionPreview: null,
subscribers: null,
videos: null,
}),
mounted() {
console.log(
"%c getChannel ",
"color: black; font-weight: bold; background: #f00; padding: .5rem .25rem; border-radius: .25rem;"
);
this.$youtube
.getChannel(`https://youtube.com/channel/${this.$route.params.id}`)
.then((channel) => {
this.channel = channel;
console.log(channel);
this.banner =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelBanner.image.sources[0].url;
this.avatar =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelProfile.avatarData.avatar.image.sources[0].url;
this.title =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelProfile.title;
this.subscribe =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelProfile.subscribeButton.subscribeButtonContent.buttonText;
this.subscribeAlt =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelProfile.subscribeButton.subscribeButtonContent.accessibilityText;
this.descriptionPreview =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelProfile.descriptionPreview.description;
this.subscribers =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelProfile.metadata.subscriberCountText;
this.videos =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelProfile.metadata.videosCountText;
});
},
};
</script>

View file

@ -1,3 +1,11 @@
<template> <template>
<div></div> <div>
<b>Description</b>
<p>{{ $store.state.channel.descriptionPreview }}</p>
<br />
<br />
<b>Links</b>
<br />
<b>More Info</b>
</div>
</template> </template>

View file

@ -133,7 +133,7 @@
: 'background darken-1' : 'background darken-1'
: '' : ''
" "
:to="video.channelUrl" to="/channel"
:style="{ :style="{
borderRadius: $store.state.tweaks.roundWatch borderRadius: $store.state.tweaks.roundWatch
? `${$store.state.tweaks.roundTweak / 2}rem` ? `${$store.state.tweaks.roundTweak / 2}rem`
@ -144,6 +144,7 @@
? '1rem' ? '1rem'
: '0', : '0',
}" }"
@click="$store.dispatch('channel/fetchChannel', video.channelUrl)"
> >
<div id="details"> <div id="details">
<div class="avatar-link mr-3"> <div class="avatar-link mr-3">

View file

@ -0,0 +1,46 @@
export const state = () => ({
avatar: null,
banner: null,
title: null,
subscribe: null,
subscribeAlt: null,
descriptionPreview: null,
subscribers: null,
videos: null,
});
export const actions = {
fetchChannel({ state }, channelUrl) {
// console.log(
// "%c getChannel ",
// "color: black; font-weight: bold; background: #f00; padding: .5rem .25rem; border-radius: .25rem;"
// );
// console.log(
// `%c${id}`,
// "color: black; font-weight: bold; background: #0f0; padding: .5rem .25rem; border-radius: .25rem;"
// );
this.$youtube
.getChannel(`https://youtube.com/${channelUrl}`)
.then((channel) => {
// console.log(channel);
state.banner =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelBanner.image.sources[0].url;
state.avatar =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelProfile.avatarData.avatar.image.sources[0].url;
state.title =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelProfile.title;
state.subscribe =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelProfile.subscribeButton.subscribeButtonContent.buttonText;
state.subscribeAlt =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelProfile.subscribeButton.subscribeButtonContent.accessibilityText;
state.descriptionPreview =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelProfile.descriptionPreview.description;
state.subscribers =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelProfile.metadata.subscriberCountText;
state.videos =
channel.header.channelMobileHeaderRenderer.channelHeader.elementRenderer.newElement.type.componentType.model.channelHeaderModel.channelProfile.metadata.videosCountText;
})
.catch((err) => {
console.log(err);
});
},
};

View file

@ -12,6 +12,6 @@
</deviceKey> </deviceKey>
</Target> </Target>
</targetSelectedWithDropDown> </targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-05-13T01:27:37.098564Z" /> <timeTargetWasSelectedWithDropDown value="2022-05-14T02:50:17.689302Z" />
</component> </component>
</project> </project>