@@ -4,6 +4,10 @@ import { computed, onMounted, type PropType, ref, toRefs, Transition } from 'vue
4
4
5
5
import type { TraktEpisodeExtended } from ' ~/models/trakt/trakt-episode.model' ;
6
6
7
+ import type { TraktSeasonExtended } from ' ~/models/trakt/trakt-season.model' ;
8
+
9
+ import type { TraktShowExtended } from ' ~/models/trakt/trakt-show.model' ;
10
+
7
11
import TitleLink from ' ~/components/common/buttons/TitleLink.vue' ;
8
12
import { ResolveExternalLinks } from ' ~/settings/external.links' ;
9
13
import { useExtensionSettingsStore } from ' ~/stores/settings/extension.store' ;
@@ -14,16 +18,53 @@ const props = defineProps({
14
18
type: Object as PropType <TraktEpisodeExtended >,
15
19
required: false ,
16
20
},
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
+ },
17
34
});
18
35
19
- const { episode } = toRefs (props );
36
+ const { mode, episode, season, show } = toRefs (props );
20
37
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
+ }
22
47
if (! episode ?.value ?.title ) return ;
23
48
return deCapitalise (episode .value ?.title );
24
49
});
25
50
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
+ }
27
68
if (! episode ?.value ?.ids ?.trakt ) return ;
28
69
return ResolveExternalLinks .search ({
29
70
type: ' episode' ,
@@ -32,6 +73,21 @@ const episodeUrl = computed(() => {
32
73
});
33
74
});
34
75
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
+
35
91
const { openTab } = useExtensionSettingsStore ();
36
92
37
93
const transition = ref (' none' );
@@ -45,25 +101,19 @@ onMounted(() => {
45
101
46
102
<template >
47
103
<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" >
55
105
<TitleLink
56
- v-if =" episodeTitle "
57
- class =" episode- title"
58
- :href =" episodeUrl "
106
+ v-if =" title "
107
+ class =" title"
108
+ :href =" url "
59
109
:component =" NH4"
60
110
@on-click =" openTab"
61
111
>
62
- {{ episodeTitle }}
112
+ {{ title }}
63
113
</TitleLink >
64
- <NSkeleton v-else class =" episode- title-skeleton" style =" width : 40 dvh" round />
114
+ <NSkeleton v-else class =" title-skeleton" style =" width : 40 dvh" round />
65
115
66
- <div v-if =" episode " >{{ episode?. overview }}</div >
116
+ <div v-if =" overview " >{{ overview }}</div >
67
117
<template v-else >
68
118
<NSkeleton style =" width : 100% " />
69
119
<NSkeleton style =" width : 100% " />
@@ -93,13 +143,13 @@ onMounted(() => {
93
143
}
94
144
}
95
145
96
- .episode {
97
- & - container {
146
+ .overview {
147
+ . container {
98
148
width : 100% ;
99
149
}
100
150
101
- & - title :deep (h4 ),
102
- & - title- skeleton {
151
+ . title :deep (h4 ),
152
+ . title- skeleton {
103
153
margin-top : 1rem ;
104
154
margin-bottom : 1rem ;
105
155
font-weight : bold ;
0 commit comments