From e542fcb8aa150634120be047bcc766f7dccd3362 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Tue, 8 Aug 2023 00:38:32 -0700 Subject: [PATCH] Memoize context values --- .../features/albums/routes/album-list-route.tsx | 11 ++++++++++- .../album-artist-detail-top-songs-list-route.tsx | 11 ++++++++--- .../artists/routes/album-artist-list-route.tsx | 11 +++++++++-- .../features/playlists/routes/playlist-list-route.tsx | 11 +++++++++-- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/renderer/features/albums/routes/album-list-route.tsx b/src/renderer/features/albums/routes/album-list-route.tsx index d80ade24..b345fb96 100644 --- a/src/renderer/features/albums/routes/album-list-route.tsx +++ b/src/renderer/features/albums/routes/album-list-route.tsx @@ -87,9 +87,18 @@ const AlbumListRoute = () => { [albumListFilter, customFilters, handlePlayQueueAdd, itemCount, server], ); + const providerValue = useMemo(() => { + return { + customFilters, + handlePlay, + id: albumArtistId ?? undefined, + pageKey, + }; + }, [albumArtistId, customFilters, handlePlay, pageKey]); + return ( - + { const itemCount = topSongsQuery?.data?.items?.length || 0; - if (detailQuery.isLoading || topSongsQuery?.isLoading) return null; + const providerValue = useMemo(() => { + return { + id: albumArtistId, + pageKey, + }; + }, [albumArtistId, pageKey]); return ( - + { ? undefined : itemCountCheck.data?.totalRecordCount; + const providerValue = useMemo(() => { + return { + id: undefined, + pageKey, + }; + }, [pageKey]); + return ( - + { ? undefined : itemCountCheck.data?.totalRecordCount; + const providerValue = useMemo(() => { + return { + id: playlistId, + pageKey, + }; + }, [playlistId]); + return ( - +