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,7 +103,9 @@ export const AlbumArtistListContent = ({ gridRef, tableRef }: AlbumArtistListCon
...page.filter,
});
const albumArtistsRes = await queryClient.fetchQuery(queryKey, async ({ signal }) =>
const albumArtistsRes = await queryClient.fetchQuery(
queryKey,
async ({ signal }) =>
api.controller.getAlbumArtistList({
query: {
limit,
@ -113,6 +115,7 @@ export const AlbumArtistListContent = ({ gridRef, tableRef }: AlbumArtistListCon
server,
signal,
}),
{ cacheTime: 1000 * 60 * 1 },
);
const albums = api.normalize.albumArtistList(albumArtistsRes, server);
@ -192,7 +195,9 @@ export const AlbumArtistListContent = ({ gridRef, tableRef }: AlbumArtistListCon
...page.filter,
});
const albumArtistsRes = await queryClient.fetchQuery(queryKey, async ({ signal }) =>
const albumArtistsRes = await queryClient.fetchQuery(
queryKey,
async ({ signal }) =>
api.controller.getAlbumArtistList({
query: {
limit,
@ -202,6 +207,7 @@ export const AlbumArtistListContent = ({ gridRef, tableRef }: AlbumArtistListCon
server,
signal,
}),
{ cacheTime: 1000 * 60 * 1 },
);
return api.normalize.albumArtistList(albumArtistsRes, server);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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