From 69db54a66c1e2f360abecc91acd8f0e18944cbb8 Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Thu, 20 Feb 2025 20:34:20 +0100 Subject: [PATCH] fix: include series, increase to 30 items --- utils/recently-added-notifications.ts | 29 ++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/utils/recently-added-notifications.ts b/utils/recently-added-notifications.ts index 40219f4a..5a551404 100644 --- a/utils/recently-added-notifications.ts +++ b/utils/recently-added-notifications.ts @@ -1,12 +1,11 @@ -import { Api, Jellyfin } from "@jellyfin/sdk"; +import { storage } from "@/utils/mmkv"; +import { Jellyfin } from "@jellyfin/sdk"; import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models"; import { getItemsApi, getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api"; -import { storage } from "@/utils/mmkv"; import * as Notifications from "expo-notifications"; import { Platform } from "react-native"; -import { getAuthHeaders } from "./jellyfin/jellyfin"; -import { getOrSetDeviceId } from "./device"; import { getDeviceName } from "react-native-device-info"; +import { getOrSetDeviceId } from "./device"; export const RECENTLY_ADDED_SENT_NOTIFICATIONS_ITEM_IDS_KEY = "notification_send_for_item_ids"; @@ -97,7 +96,7 @@ export async function fetchAndStoreRecentlyAdded( const response1 = await getItemsApi(api).getItems({ userId: userId, - limit: 5, + limit: 10, recursive: true, includeItemTypes: ["Episode"], sortOrder: ["Descending"], @@ -105,12 +104,20 @@ export async function fetchAndStoreRecentlyAdded( }); const response2 = await getItemsApi(api).getItems({ userId: userId, - limit: 5, + limit: 10, recursive: true, includeItemTypes: ["Movie"], sortOrder: ["Descending"], sortBy: ["DateCreated"], }); + const response3 = await getItemsApi(api).getItems({ + userId: userId, + limit: 10, + recursive: true, + includeItemTypes: ["Series"], + sortOrder: ["Descending"], + sortBy: ["DateCreated"], + }); const newEpisodes = response1.data.Items?.map((item) => ({ @@ -128,8 +135,16 @@ export async function fetchAndStoreRecentlyAdded( Type: item.Type, })) ?? []; + const newSeries = + response3.data.Items?.map((item) => ({ + Id: item.Id, + Name: item.Name, + DateCreated: item.DateCreated, + Type: item.Type, + })) ?? []; + const newIds: string[] = []; - const items = [...newEpisodes, ...newMovies]; + const items = [...newEpisodes, ...newMovies, ...newSeries]; // Don't send initial mass-notifications if there are no previously sent notifications if (alreadySentItemIds.length === 0) {