diff --git a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx index e223014..cbdb52c 100644 --- a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx @@ -1,5 +1,5 @@ -import { useQuery } from "convex/react" import { Stack, useLocalSearchParams } from "expo-router" +import { useEffect } from "react" import { FlatList, Pressable, StyleSheet, Text, View } from "react-native" import { Ionicons } from "@expo/vector-icons" @@ -9,11 +9,13 @@ import { MediaActionMenu, MediaContextMenu, } from "@/components/media-actions-sheet" -import { Button, LoadingView } from "@/components/ui/primitives" +import { CollectionDetailSkeleton } from "@/components/skeletons" +import { Button } from "@/components/ui/primitives" import { contentBottomInset } from "@/components/player" import { useFavorites } from "@/contexts/favorites" import { usePlaybackActions } from "@/contexts/playback" import { useServerConfig } from "@/contexts/server-config" +import { useCachedQuery } from "@/hooks/use-cached-query" import { useCoverBackgroundColor } from "@/hooks/use-cover-background-color" import { useMediaMenuActions } from "@/hooks/use-media-menu-actions" import { api } from "@otunes/convex/_generated/api" @@ -21,6 +23,7 @@ import type { Id } from "@otunes/convex/_generated/dataModel" import type { BrowseAlbumTrack } from "@otunes/convex/types" import { formatDuration, formatMetadata } from "@/lib/format" import { useAppNavigation } from "@/lib/app-navigation" +import { albumDetailSongs, rememberSongs } from "@/lib/song-cache" import { albumCoverUrl } from "@/lib/urls" import { radius, spacing, useThemeColors } from "@/lib/theme" @@ -29,7 +32,7 @@ export default function AlbumScreen() { const { push } = useAppNavigation() const colors = useThemeColors() const { config } = useServerConfig() - const album = useQuery( + const album = useCachedQuery( api.library.browseAlbumDetail, typeof id === "string" ? { id: id as Id<"albums"> } : "skip" ) @@ -49,6 +52,12 @@ export default function AlbumScreen() { colors.background ) + useEffect(() => { + if (album) { + rememberSongs(albumDetailSongs(album)) + } + }, [album]) + if (album === undefined || !config) { return ( <> @@ -58,7 +67,7 @@ export default function AlbumScreen() { headerLargeTitle: false, }} /> - + ) } @@ -159,14 +168,14 @@ export default function AlbumScreen() {