From bcdaf7d9214a16473b70bd1078a047dad76ab870 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 11 Jan 2024 22:07:08 -0800 Subject: feat(list): recache notifications --- src/lib/AniList/media.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/lib/AniList') diff --git a/src/lib/AniList/media.ts b/src/lib/AniList/media.ts index 2becc0d5..e65c90cd 100644 --- a/src/lib/AniList/media.ts +++ b/src/lib/AniList/media.ts @@ -4,6 +4,7 @@ import anime from '$stores/anime'; import manga from '$stores/manga'; import settings from '$stores/settings'; import lastPruneTimes from '$stores/lastPruneTimes'; +import { options as getOptions, type Options } from '$lib/Notification/options'; export enum Type { Anime, @@ -145,25 +146,35 @@ interface CollectionOptions { includeCompleted?: boolean; forcePrune?: boolean; all?: boolean; + addNotification?: (preferences: Options) => void; + notificationType?: string; } interface NonNullCollectionOptions { includeCompleted: boolean; forcePrune: boolean; all?: boolean; + addNotification?: (preferences: Options) => void; + notificationType?: string; } const assignDefaultOptions = (options: CollectionOptions) => { const nonNullOptions: NonNullCollectionOptions = { includeCompleted: false, forcePrune: false, - all: false + all: false, + addNotification: undefined, + notificationType: undefined }; if (options.includeCompleted !== undefined) nonNullOptions.includeCompleted = options.includeCompleted; if (options.forcePrune !== undefined) nonNullOptions.forcePrune = options.forcePrune; if (options.all !== undefined) nonNullOptions.all = options.all; + if (options.addNotification !== undefined) + nonNullOptions.addNotification = options.addNotification; + if (options.notificationType !== undefined) + nonNullOptions.notificationType = options.notificationType; return nonNullOptions; }; @@ -233,6 +244,14 @@ export const mediaListCollection = async ( ) ); + if (options.addNotification) + options.addNotification( + getOptions({ + heading: options.notificationType ? options.notificationType : Type[type], + description: 'Re-cached media lists from AniList' + }) + ); + return flattenLists(userIdResponse['data']['MediaListCollection']['lists'], options.all); }; -- cgit v1.2.3