@@ -11,9 +11,10 @@ import type {
11
11
import FloatingButton from ' ~/components/common/buttons/FloatingButton.vue' ;
12
12
import ListScroll from ' ~/components/common/list/ListScroll.vue' ;
13
13
import { useHistoryStore , useHistoryStoreRefs } from ' ~/stores/data/history.store' ;
14
- import { useImageStore } from ' ~/stores/data/image.store' ;
14
+ import { useImageStore , useImageStoreRefs } from ' ~/stores/data/image.store' ;
15
15
import { useUserSettingsStoreRefs } from ' ~/stores/settings/user.store' ;
16
16
import { useI18n } from ' ~/utils' ;
17
+ import { findClosestMatch } from ' ~/utils/math.utils' ;
17
18
18
19
const { filteredHistory, pagination, loading, pageSize, belowThreshold } =
19
20
useHistoryStoreRefs ();
@@ -36,15 +37,19 @@ onDeactivated(() => {
36
37
37
38
onMounted (() => {
38
39
watch (user , () => {
39
- if (active .value ) {
40
- fetchHistory ();
41
- } else {
42
- clearState ();
43
- }
40
+ if (active .value ) fetchHistory ();
41
+ else clearState ();
44
42
});
45
43
});
46
44
47
45
const { getImageUrl } = useImageStore ();
46
+ const { imageSizes } = useImageStoreRefs ();
47
+
48
+ const size = computed (() =>
49
+ imageSizes .value ?.poster ?.length
50
+ ? findClosestMatch (200 , imageSizes .value .poster )
51
+ : ' original' ,
52
+ );
48
53
49
54
const history = computed <ListScrollItem []>(() => {
50
55
const array = filteredHistory .value ;
@@ -57,18 +62,22 @@ const history = computed<ListScrollItem[]>(() => {
57
62
else if (' season' in _item ) _item .type = ' season' ;
58
63
else if (' show' in _item ) _item .type = ' show' ;
59
64
60
- if (! _item ?.poster && _item .type ) {
61
- if ( _item ?. movie ?. ids ?. tmdb ) {
62
- _item . poster = getImageUrl ( {
65
+ if (! _item ?.poster && _item .type && _item ?. movie ?. ids ?. tmdb ) {
66
+ _item . poster = getImageUrl (
67
+ {
63
68
id: _item .movie .ids .tmdb ,
64
69
type: _item .type ,
65
- });
66
- } else if (_item ?.show ?.ids ?.tmdb ) {
67
- _item .poster = getImageUrl ({
70
+ },
71
+ size .value ,
72
+ );
73
+ } else if (! _item ?.poster && _item .type && _item ?.show ?.ids ?.tmdb ) {
74
+ _item .poster = getImageUrl (
75
+ {
68
76
id: _item .show .ids .tmdb ,
69
77
type: ' show' ,
70
- });
71
- }
78
+ },
79
+ size .value ,
80
+ );
72
81
}
73
82
74
83
if (! item .watched_at ) return _item ;
0 commit comments