Skip to content

Commit 02cd3d3

Browse files
committed
feat(list): adds collected & watched date on hover
1 parent 17f14ac commit 02cd3d3

File tree

1 file changed

+47
-13
lines changed

1 file changed

+47
-13
lines changed

src/components/common/list/ListItemPanel.vue

+47-13
Original file line numberDiff line numberDiff line change
@@ -160,25 +160,48 @@ const movieWatched = computed(() => {
160160
return getMovieWatched(_item.meta.ids.movie.trakt)?.value;
161161
});
162162
163+
const moviePlayed = computed(() => {
164+
if (!showPlayed.value) return;
165+
if (movieWatched.value !== undefined) return movieWatched.value?.last_watched_at;
166+
return movieHistory.value?.watched_at;
167+
});
168+
169+
const episodePlayed = computed(() => {
170+
if (!showPlayed.value) return;
171+
if (episodeProgress.value !== undefined) {
172+
return {
173+
date: episodeProgress.value?.date,
174+
completed: episodeProgress.value?.completed,
175+
};
176+
}
177+
return {
178+
date: episodeHistory.value?.watched_at,
179+
completed: !!episodeHistory.value,
180+
};
181+
});
182+
163183
const played = computed(() => {
164184
if (!showPlayed.value) return false;
165-
const _item = item?.value;
166-
if (_item?.type === 'movie') {
167-
const _watched = movieWatched.value;
168-
if (_watched !== undefined) return !!_watched.plays;
169-
return !!movieHistory.value;
185+
if (item?.value?.type === 'movie') return !!moviePlayed.value;
186+
if (item?.value?.type !== 'episode') return false;
187+
return episodePlayed.value?.completed;
188+
});
189+
190+
const playedDate = computed(() => {
191+
if (!played.value) return;
192+
if (item?.value?.type === 'movie') {
193+
if (!moviePlayed.value) return;
194+
return new Date(moviePlayed.value).toLocaleString();
170195
}
171-
if (_item?.type !== 'episode') return false;
172-
const _progress = episodeProgress.value;
173-
if (_progress !== undefined) return _progress.completed;
174-
return !!episodeHistory.value;
196+
if (!episodePlayed.value?.date) return;
197+
return new Date(episodePlayed.value?.date).toLocaleString();
175198
});
176199
177200
const collected = computed(() => {
178201
if (!showCollected.value) return false;
179202
const _item = item?.value;
180203
if (_item?.type === 'movie' && _item?.meta?.ids?.movie?.trakt) {
181-
return getMovieCollected(_item.meta.ids.movie.trakt)?.value;
204+
return getMovieCollected(_item.meta.ids.movie.trakt)?.value?.collected_at;
182205
}
183206
if (_item?.type !== 'episode') return false;
184207
const _collection = collection.value;
@@ -189,7 +212,13 @@ const collected = computed(() => {
189212
if (!_season || !_episode) return false;
190213
return _collection.seasons
191214
?.find(s => s.number === _season)
192-
?.episodes?.find(e => e.number === _episode)?.completed;
215+
?.episodes?.find(e => e.number === _episode)?.date;
216+
});
217+
218+
const collectedDate = computed(() => {
219+
if (!collected.value) return;
220+
if (typeof collected.value !== 'string') return;
221+
return new Date(collected.value).toLocaleString();
193222
});
194223
195224
const { progressType } = useExtensionSettingsStoreRefs();
@@ -272,7 +301,10 @@ const onTagClick = (url?: string) => {
272301
size="small"
273302
type="info"
274303
:bordered="false"
275-
:title="i18n('collected', 'common', 'tooltip')"
304+
:title="
305+
i18n('collected', 'common', 'tooltip') +
306+
(collectedDate ? `: ${ collectedDate }` : '')
307+
"
276308
>
277309
<template #icon>
278310
<NIcon :component="IconGrid" />
@@ -288,7 +320,9 @@ const onTagClick = (url?: string) => {
288320
size="small"
289321
type="primary"
290322
:bordered="false"
291-
:title="i18n('watched', 'common', 'tooltip')"
323+
:title="
324+
i18n('watched', 'common', 'tooltip') + (playedDate ? `: ${ playedDate }` : '')
325+
"
292326
>
293327
<template #icon>
294328
<NIcon :component="IconPlayFilled" />

0 commit comments

Comments
 (0)