From 3f704f1f350a5eccfc8a2e835c1376f2a518e924 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Sat, 29 Nov 2025 17:54:57 -0800 Subject: [PATCH] add 12 hour cache for list count queries --- src/renderer/features/albums/api/album-api.ts | 2 ++ src/renderer/features/artists/api/artists-api.ts | 4 ++++ src/renderer/features/genres/api/genres-api.ts | 2 ++ src/renderer/features/playlists/api/playlists-api.ts | 2 ++ src/renderer/features/songs/api/songs-api.ts | 2 ++ 5 files changed, 12 insertions(+) diff --git a/src/renderer/features/albums/api/album-api.ts b/src/renderer/features/albums/api/album-api.ts index 933eae8b5..fc556cedb 100644 --- a/src/renderer/features/albums/api/album-api.ts +++ b/src/renderer/features/albums/api/album-api.ts @@ -36,6 +36,7 @@ export const albumQueries = { }, listCount: (args: QueryHookArgs>) => { return queryOptions({ + gcTime: 1000 * 60 * 60 * 12, queryFn: ({ signal }) => { return api.controller.getAlbumListCount({ apiClientProps: { serverId: args.serverId, signal }, @@ -47,6 +48,7 @@ export const albumQueries = { args.query, args.query?.artistIds?.length === 1 ? args.query?.artistIds[0] : undefined, ), + staleTime: 1000 * 60 * 60 * 12, ...args.options, }); }, diff --git a/src/renderer/features/artists/api/artists-api.ts b/src/renderer/features/artists/api/artists-api.ts index cb01ea6fa..f72625fc7 100644 --- a/src/renderer/features/artists/api/artists-api.ts +++ b/src/renderer/features/artists/api/artists-api.ts @@ -38,6 +38,7 @@ export const artistsQueries = { }, albumArtistListCount: (args: QueryHookArgs>) => { return queryOptions({ + gcTime: 1000 * 60 * 60 * 12, queryFn: ({ signal }) => { return api.controller.getAlbumArtistListCount({ apiClientProps: { serverId: args.serverId, signal }, @@ -48,6 +49,7 @@ export const artistsQueries = { args.serverId, Object.keys(args.query).length === 0 ? undefined : args.query, ), + staleTime: 1000 * 60 * 60 * 12, ...args.options, }); }, @@ -65,6 +67,7 @@ export const artistsQueries = { }, artistListCount: (args: QueryHookArgs>) => { return queryOptions({ + gcTime: 1000 * 60 * 60 * 12, queryFn: ({ signal }) => { return api.controller .getArtistList({ @@ -77,6 +80,7 @@ export const artistsQueries = { args.serverId, Object.keys(args.query).length === 0 ? undefined : args.query, ), + staleTime: 1000 * 60 * 60 * 12, ...args.options, }); }, diff --git a/src/renderer/features/genres/api/genres-api.ts b/src/renderer/features/genres/api/genres-api.ts index 13965b259..13901f8a4 100644 --- a/src/renderer/features/genres/api/genres-api.ts +++ b/src/renderer/features/genres/api/genres-api.ts @@ -27,6 +27,7 @@ export const genresQueries = { }, listCount: (args: QueryHookArgs>) => { return queryOptions({ + gcTime: 1000 * 60 * 60 * 12, queryFn: ({ signal }) => { return api.controller .getGenreList({ @@ -39,6 +40,7 @@ export const genresQueries = { args.serverId, Object.keys(args.query).length === 0 ? undefined : args.query, ), + staleTime: 1000 * 60 * 60 * 12, ...args.options, }); }, diff --git a/src/renderer/features/playlists/api/playlists-api.ts b/src/renderer/features/playlists/api/playlists-api.ts index 773026deb..a6e6ff1fa 100644 --- a/src/renderer/features/playlists/api/playlists-api.ts +++ b/src/renderer/features/playlists/api/playlists-api.ts @@ -38,6 +38,7 @@ export const playlistsQueries = { }, listCount: (args: QueryHookArgs>) => { return queryOptions({ + gcTime: 1000 * 60 * 60 * 12, queryFn: ({ signal }) => { return api.controller.getPlaylistListCount({ apiClientProps: { serverId: args.serverId, signal }, @@ -48,6 +49,7 @@ export const playlistsQueries = { args.serverId || '', Object.keys(args.query).length === 0 ? undefined : args.query, ), + staleTime: 1000 * 60 * 60 * 12, ...args.options, }); }, diff --git a/src/renderer/features/songs/api/songs-api.ts b/src/renderer/features/songs/api/songs-api.ts index 6af26db8d..ac52bffaa 100644 --- a/src/renderer/features/songs/api/songs-api.ts +++ b/src/renderer/features/songs/api/songs-api.ts @@ -21,6 +21,7 @@ export const songsQueries = { }, listCount: (args: QueryHookArgs>) => { return queryOptions({ + gcTime: 1000 * 60 * 60 * 12, queryFn: ({ signal }) => { return api.controller.getSongListCount({ apiClientProps: { serverId: args.serverId, signal }, @@ -31,6 +32,7 @@ export const songsQueries = { args.serverId, Object.keys(args.query).length === 0 ? undefined : args.query, ), + staleTime: 1000 * 60 * 60 * 12, ...args.options, }); },