Skip to content

Commit a922574

Browse files
committed
feat(panel): adds show & season overview support
1 parent a1e9407 commit a922574

File tree

2 files changed

+81
-21
lines changed

2 files changed

+81
-21
lines changed

src/components/views/panel/ShowPanel.vue

+11-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ const panelType = computed<'show' | 'season' | 'episode'>(() => {
5959
return 'show';
6060
});
6161
62+
const season = computed(() => {
63+
if (seasonNb?.value === undefined) return;
64+
return seasons.value?.[seasonNb.value];
65+
});
66+
6267
const showTitle = computed(() => {
6368
if (!show.value?.title) return;
6469
return deCapitalise(show.value.title);
@@ -153,7 +158,12 @@ const titleUrl = computed(() => {
153158
:episode-number="episodeNb"
154159
/>
155160

156-
<ShowPanelOverview v-if="panelType === 'episode'" :episode="episode" />
161+
<ShowPanelOverview
162+
:episode="episode"
163+
:season="season"
164+
:show="show"
165+
:mode="panelType"
166+
/>
157167
</NFlex>
158168
</template>
159169

src/components/views/panel/ShowPanelOverview.vue

+70-20
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { computed, onMounted, type PropType, ref, toRefs, Transition } from 'vue
44
55
import type { TraktEpisodeExtended } from '~/models/trakt/trakt-episode.model';
66
7+
import type { TraktSeasonExtended } from '~/models/trakt/trakt-season.model';
8+
9+
import type { TraktShowExtended } from '~/models/trakt/trakt-show.model';
10+
711
import TitleLink from '~/components/common/buttons/TitleLink.vue';
812
import { ResolveExternalLinks } from '~/settings/external.links';
913
import { useExtensionSettingsStore } from '~/stores/settings/extension.store';
@@ -14,16 +18,53 @@ const props = defineProps({
1418
type: Object as PropType<TraktEpisodeExtended>,
1519
required: false,
1620
},
21+
season: {
22+
type: Object as PropType<TraktSeasonExtended>,
23+
required: false,
24+
},
25+
show: {
26+
type: Object as PropType<TraktShowExtended>,
27+
required: false,
28+
},
29+
mode: {
30+
type: String as PropType<'show' | 'season' | 'episode'>,
31+
required: false,
32+
default: 'episode',
33+
},
1734
});
1835
19-
const { episode } = toRefs(props);
36+
const { mode, episode, season, show } = toRefs(props);
2037
21-
const episodeTitle = computed(() => {
38+
const title = computed(() => {
39+
if (mode.value === 'show') {
40+
if (!show?.value?.title) return;
41+
return deCapitalise(show.value.title);
42+
}
43+
if (mode.value === 'season') {
44+
if (!season?.value?.title) return;
45+
return deCapitalise(season.value.title);
46+
}
2247
if (!episode?.value?.title) return;
2348
return deCapitalise(episode.value?.title);
2449
});
2550
26-
const episodeUrl = computed(() => {
51+
const url = computed(() => {
52+
if (mode.value === 'show') {
53+
if (!show?.value?.ids?.trakt) return;
54+
return ResolveExternalLinks.search({
55+
type: 'show',
56+
source: 'trakt',
57+
id: show.value.ids.trakt,
58+
});
59+
}
60+
if (mode.value === 'season') {
61+
if (!season?.value?.ids?.trakt) return;
62+
return ResolveExternalLinks.search({
63+
type: 'season',
64+
source: 'trakt',
65+
id: season.value.ids.trakt,
66+
});
67+
}
2768
if (!episode?.value?.ids?.trakt) return;
2869
return ResolveExternalLinks.search({
2970
type: 'episode',
@@ -32,6 +73,21 @@ const episodeUrl = computed(() => {
3273
});
3374
});
3475
76+
const overview = computed(() => {
77+
if (mode.value === 'show') {
78+
if (!show?.value) return;
79+
return show?.value?.overview ?? '-';
80+
}
81+
if (mode.value === 'season') {
82+
if (!season?.value) return;
83+
return season?.value?.overview ?? show?.value?.overview ?? '-';
84+
}
85+
if (!episode?.value) return;
86+
return episode?.value?.overview ?? '-';
87+
});
88+
89+
const key = computed(() => `episode-${episode?.value?.ids.trakt}`);
90+
3591
const { openTab } = useExtensionSettingsStore();
3692
3793
const transition = ref('none');
@@ -45,25 +101,19 @@ onMounted(() => {
45101

46102
<template>
47103
<Transition :name="transition" mode="out-in">
48-
<NFlex
49-
:key="`episode-${episode?.ids.trakt}`"
50-
justify="center"
51-
align="center"
52-
vertical
53-
class="episode-container"
54-
>
104+
<NFlex :key="key" justify="center" align="center" vertical class="overview container">
55105
<TitleLink
56-
v-if="episodeTitle"
57-
class="episode-title"
58-
:href="episodeUrl"
106+
v-if="title"
107+
class="title"
108+
:href="url"
59109
:component="NH4"
60110
@on-click="openTab"
61111
>
62-
{{ episodeTitle }}
112+
{{ title }}
63113
</TitleLink>
64-
<NSkeleton v-else class="episode-title-skeleton" style="width: 40dvh" round />
114+
<NSkeleton v-else class="title-skeleton" style="width: 40dvh" round />
65115

66-
<div v-if="episode">{{ episode?.overview }}</div>
116+
<div v-if="overview">{{ overview }}</div>
67117
<template v-else>
68118
<NSkeleton style="width: 100%" />
69119
<NSkeleton style="width: 100%" />
@@ -93,13 +143,13 @@ onMounted(() => {
93143
}
94144
}
95145
96-
.episode {
97-
&-container {
146+
.overview {
147+
.container {
98148
width: 100%;
99149
}
100150
101-
&-title:deep(h4),
102-
&-title-skeleton {
151+
.title:deep(h4),
152+
.title-skeleton {
103153
margin-top: 1rem;
104154
margin-bottom: 1rem;
105155
font-weight: bold;

0 commit comments

Comments
 (0)