Skip to content

Commit 7e06f4e

Browse files
committed
fix(statistics): update show ratings on mounted instead of computed
1 parent e09d9c7 commit 7e06f4e

File tree

3 files changed

+66
-52
lines changed

3 files changed

+66
-52
lines changed

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
"release:changelog": "extract-changelog-release > RELEASE.md"
5252
},
5353
"dependencies": {
54-
"@dvcol/base-http-client": "^1.15.2",
55-
"@dvcol/common-utils": "^1.13.1",
56-
"@dvcol/simkl-http-client": "^1.1.6",
57-
"@dvcol/tmdb-http-client": "^1.3.8",
58-
"@dvcol/trakt-http-client": "^1.4.14",
54+
"@dvcol/base-http-client": "^1.16.0",
55+
"@dvcol/common-utils": "^1.14.0",
56+
"@dvcol/simkl-http-client": "^1.1.7",
57+
"@dvcol/tmdb-http-client": "^1.3.9",
58+
"@dvcol/trakt-http-client": "^1.4.15",
5959
"@dvcol/web-extension-utils": "^3.3.2",
6060
"@vue/devtools": "^7.0.15",
6161
"iso-3166-2": "^1.0.0",

pnpm-lock.yaml

+33-33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/views/panel/PanelShowStatistics.vue

+28-14
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
type TraktShowExtended,
88
type TraktSyncRatingValue,
99
} from '@dvcol/trakt-http-client/models';
10-
import { computed, type PropType, toRefs } from 'vue';
10+
import { computed, onMounted, type PropType, toRefs, watch } from 'vue';
1111
1212
import type { RatingItem } from '~/models/rating.model';
1313
@@ -82,27 +82,34 @@ const scoreLoading = computed(() => {
8282
return getLoading(TraktRatingType.Shows);
8383
});
8484
85-
const score = computed(() => {
86-
if (!showId?.value) return null;
85+
const scoreIds = computed(() => {
86+
if (!enableRatings.value) return {};
8787
88-
let id: string;
89-
let type: TraktRatingTypes;
88+
let id: string | undefined;
89+
let type: TraktRatingTypes | undefined;
9090
91+
if (!showId.value) return { id, type };
9192
if (mode.value === 'show') {
9293
id = showId.value.toString();
9394
type = TraktRatingType.Shows;
94-
} else if (mode.value === 'season') {
95-
if (!seasonId.value) return null;
96-
id = `${showId.value}-${seasonId.value}`;
95+
return { id, type };
96+
}
97+
if (mode.value === 'season') {
9798
type = TraktRatingType.Seasons;
98-
} else if (mode.value === 'episode') {
99-
if (!episodeId.value) return null;
100-
id = `${showId.value}-${episodeId.value}`;
99+
if (seasonId.value) id = `${showId.value}-${seasonId.value}`;
100+
return { id, type };
101+
}
102+
if (mode.value === 'episode') {
101103
type = TraktRatingType.Episodes;
102-
} else {
103-
return null;
104+
if (episodeId.value) id = `${showId.value}-${episodeId.value}`;
105+
return { id, type };
104106
}
105-
if (enableRatings.value) loadRatings(type, id);
107+
return { id, type };
108+
});
109+
110+
const score = computed(() => {
111+
const { id, type } = scoreIds.value;
112+
if (!id || !type) return null;
106113
return getRatings(type, id);
107114
});
108115
@@ -242,6 +249,13 @@ const onScoreEdit = async (_score: TraktSyncRatingValue) => {
242249
],
243250
});
244251
};
252+
253+
onMounted(() => {
254+
watch(scoreIds, ({ id, type }) => {
255+
if (!id || !type) return;
256+
loadRatings(type, id);
257+
});
258+
});
245259
</script>
246260

247261
<template>

0 commit comments

Comments
 (0)