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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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