Skip to content

Commit 6b611da

Browse files
committed
fix(cache): evict calendar cache on collection and watchlist
1 parent 56ef226 commit 6b611da

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/stores/data/activity.store.ts

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const useActivityStore = defineStore('data.activity', () => {
7171
changed?.movies?.watchlisted_at
7272
) {
7373
TraktService.evict.watchlist();
74+
TraktService.evict.calendar();
7475
logger.info('Evicted watchlist');
7576
}
7677
if (changed?.collaborations?.updated_at || changed?.lists?.updated_at) {
@@ -79,10 +80,12 @@ export const useActivityStore = defineStore('data.activity', () => {
7980
}
8081
if (changed?.episodes?.collected_at) {
8182
TraktService.evict.collection.show();
83+
TraktService.evict.calendar();
8284
logger.info('Evicted show collection');
8385
}
8486
if (changed?.movies?.collected_at) {
8587
TraktService.evict.collection.movie();
88+
TraktService.evict.calendar();
8689
logger.info('Evicted movie collection');
8790
}
8891
if (changed?.favorites?.updated_at) {

src/stores/data/list.store.ts

+7
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ import IconList from '~/components/icons/IconList.vue';
1717
import { ListScrollItemType } from '~/models/list-scroll.model';
1818
import { NotificationService } from '~/services/notification.service';
1919
import { TraktService } from '~/services/trakt.service';
20+
import { useActivityStore } from '~/stores/data/activity.store';
2021
import { logger } from '~/stores/settings/log.store';
2122
import { useUserSettingsStoreRefs } from '~/stores/settings/user.store';
2223
import { useI18n } from '~/utils';
2324
import { storage } from '~/utils/browser/browser-storage.utils';
25+
import { debounce } from '~/utils/debounce.utils';
2426
import { debounceLoading, useBelowThreshold, useLoadingPlaceholder, useSearchFilter } from '~/utils/store.utils';
2527
import { clearProxy } from '~/utils/vue.utils';
2628

@@ -314,6 +316,10 @@ export const useListStore = defineStore('data.list', () => {
314316

315317
const i18n = useI18n('common', 'notification');
316318

319+
const { fetchActivity } = useActivityStore();
320+
321+
const updateActivity = debounce(fetchActivity, 1000);
322+
317323
const addToOrRemoveFromList = async ({
318324
list,
319325
itemType,
@@ -390,6 +396,7 @@ export const useListStore = defineStore('data.list', () => {
390396
} finally {
391397
typeItemLoading[listType]![itemType]![itemIds.trakt.toString()] = false;
392398
typeLoading[listType] = false;
399+
updateActivity();
393400
}
394401
};
395402

0 commit comments

Comments
 (0)