Set 1 minute cache time on manual query fetches

This commit is contained in:
jeffvli 2023-01-06 03:33:11 -08:00
parent 8bd1cc80bc
commit 0a82438beb
8 changed files with 132 additions and 102 deletions

View file

@ -103,16 +103,19 @@ export const AlbumArtistListContent = ({ gridRef, tableRef }: AlbumArtistListCon
...page.filter,
});
const albumArtistsRes = await queryClient.fetchQuery(queryKey, async ({ signal }) =>
api.controller.getAlbumArtistList({
query: {
limit,
startIndex,
...page.filter,
},
server,
signal,
}),
const albumArtistsRes = await queryClient.fetchQuery(
queryKey,
async ({ signal }) =>
api.controller.getAlbumArtistList({
query: {
limit,
startIndex,
...page.filter,
},
server,
signal,
}),
{ cacheTime: 1000 * 60 * 1 },
);
const albums = api.normalize.albumArtistList(albumArtistsRes, server);
@ -192,16 +195,19 @@ export const AlbumArtistListContent = ({ gridRef, tableRef }: AlbumArtistListCon
...page.filter,
});
const albumArtistsRes = await queryClient.fetchQuery(queryKey, async ({ signal }) =>
api.controller.getAlbumArtistList({
query: {
limit,
startIndex,
...page.filter,
},
server,
signal,
}),
const albumArtistsRes = await queryClient.fetchQuery(
queryKey,
async ({ signal }) =>
api.controller.getAlbumArtistList({
query: {
limit,
startIndex,
...page.filter,
},
server,
signal,
}),
{ cacheTime: 1000 * 60 * 1 },
);
return api.normalize.albumArtistList(albumArtistsRes, server);

View file

@ -123,16 +123,19 @@ export const AlbumArtistListHeader = ({ gridRef, tableRef }: AlbumArtistListHead
...filters,
});
const albums = await queryClient.fetchQuery(queryKey, async ({ signal }) =>
api.controller.getAlbumArtistList({
query: {
limit,
startIndex,
...filters,
},
server,
signal,
}),
const albums = await queryClient.fetchQuery(
queryKey,
async ({ signal }) =>
api.controller.getAlbumArtistList({
query: {
limit,
startIndex,
...filters,
},
server,
signal,
}),
{ cacheTime: 1000 * 60 * 1 },
);
return api.normalize.albumArtistList(albums, server);
@ -157,16 +160,19 @@ export const AlbumArtistListHeader = ({ gridRef, tableRef }: AlbumArtistListHead
...filters,
});
const albumArtistsRes = await queryClient.fetchQuery(queryKey, async ({ signal }) =>
api.controller.getAlbumArtistList({
query: {
limit,
startIndex,
...filters,
},
server,
signal,
}),
const albumArtistsRes = await queryClient.fetchQuery(
queryKey,
async ({ signal }) =>
api.controller.getAlbumArtistList({
query: {
limit,
startIndex,
...filters,
},
server,
signal,
}),
{ cacheTime: 1000 * 60 * 1 },
);
const albumArtists = api.normalize.albumArtistList(albumArtistsRes, server);

View file

@ -103,17 +103,20 @@ export const PlaylistDetailSongListContent = ({ tableRef }: PlaylistDetailConten
...filters,
});
const songsRes = await queryClient.fetchQuery(queryKey, async ({ signal }) =>
api.controller.getPlaylistSongList({
query: {
id: playlistId,
limit,
startIndex,
...filters,
},
server,
signal,
}),
const songsRes = await queryClient.fetchQuery(
queryKey,
async ({ signal }) =>
api.controller.getPlaylistSongList({
query: {
id: playlistId,
limit,
startIndex,
...filters,
},
server,
signal,
}),
{ cacheTime: 1000 * 60 * 1 },
);
const songs = api.normalize.songList(songsRes, server);

View file

@ -138,17 +138,20 @@ export const PlaylistDetailSongListHeader = ({
...filters,
});
const songsRes = await queryClient.fetchQuery(queryKey, async ({ signal }) =>
api.controller.getPlaylistSongList({
query: {
id: playlistId,
limit,
startIndex,
...filters,
},
server,
signal,
}),
const songsRes = await queryClient.fetchQuery(
queryKey,
async ({ signal }) =>
api.controller.getPlaylistSongList({
query: {
id: playlistId,
limit,
startIndex,
...filters,
},
server,
signal,
}),
{ cacheTime: 1000 * 60 * 1 },
);
const songs = api.normalize.songList(songsRes, server);

View file

@ -85,16 +85,19 @@ export const PlaylistListContent = ({ tableRef }: PlaylistListContentProps) => {
...page.filter,
});
const playlistsRes = await queryClient.fetchQuery(queryKey, async ({ signal }) =>
api.controller.getPlaylistList({
query: {
limit,
startIndex,
...page.filter,
},
server,
signal,
}),
const playlistsRes = await queryClient.fetchQuery(
queryKey,
async ({ signal }) =>
api.controller.getPlaylistList({
query: {
limit,
startIndex,
...page.filter,
},
server,
signal,
}),
{ cacheTime: 1000 * 60 * 1 },
);
const playlists = api.normalize.playlistList(playlistsRes, server);

View file

@ -88,16 +88,19 @@ export const PlaylistListHeader = ({ tableRef }: PlaylistListHeaderProps) => {
...pageFilters,
});
const playlistsRes = await queryClient.fetchQuery(queryKey, async ({ signal }) =>
api.controller.getPlaylistList({
query: {
limit,
startIndex,
...pageFilters,
},
server,
signal,
}),
const playlistsRes = await queryClient.fetchQuery(
queryKey,
async ({ signal }) =>
api.controller.getPlaylistList({
query: {
limit,
startIndex,
...pageFilters,
},
server,
signal,
}),
{ cacheTime: 1000 * 60 * 1 },
);
const playlists = api.normalize.playlistList(playlistsRes, server);

View file

@ -86,16 +86,19 @@ export const SongListContent = ({ tableRef }: SongListContentProps) => {
...page.filter,
});
const songsRes = await queryClient.fetchQuery(queryKey, async ({ signal }) =>
api.controller.getSongList({
query: {
limit,
startIndex,
...page.filter,
},
server,
signal,
}),
const songsRes = await queryClient.fetchQuery(
queryKey,
async ({ signal }) =>
api.controller.getSongList({
query: {
limit,
startIndex,
...page.filter,
},
server,
signal,
}),
{ cacheTime: 1000 * 60 * 1 },
);
const songs = api.normalize.songList(songsRes, server);

View file

@ -118,16 +118,19 @@ export const SongListHeader = ({ tableRef }: SongListHeaderProps) => {
...pageFilters,
});
const songsRes = await queryClient.fetchQuery(queryKey, async ({ signal }) =>
api.controller.getSongList({
query: {
limit,
startIndex,
...pageFilters,
},
server,
signal,
}),
const songsRes = await queryClient.fetchQuery(
queryKey,
async ({ signal }) =>
api.controller.getSongList({
query: {
limit,
startIndex,
...pageFilters,
},
server,
signal,
}),
{ cacheTime: 1000 * 60 * 1 },
);
const songs = api.normalize.songList(songsRes, server);