fix: render downloaded albums in offline library tab#14284
Open
dylanjeffers wants to merge 1 commit intomainfrom
Open
fix: render downloaded albums in offline library tab#14284dylanjeffers wants to merge 1 commit intomainfrom
dylanjeffers wants to merge 1 commit intomainfrom
Conversation
The offline branch in useLibraryCollections returned the raw string keys of collectionStatus, but the TanStack collection cache is keyed by numeric ID — so each CollectionCard's useCollection lookup missed the cache and rendered CollectionCardSkeleton forever. The branch also included the literal 'favorites' bookkeeping key and never filtered by collectionType, so the Albums tab and Playlists tab both received mixed, unresolvable IDs. Convert offline IDs to numbers, drop the 'favorites' sentinel, look up the cached collections, and filter by is_album per tab. Also surface isPending/isLoading from the disk-rehydration flag when offline so the outer skeleton stops gating on the network query that's paused offline. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useLibraryCollections's offline branch returnedObject.keys(collectionStatus)directly. Three problems compounded:useCollection(used inside eachCollectionCard) keys its TanStack cache by number — every per-card lookup missed cache, fell toif (!partialCollection) return <CollectionCardSkeleton />(CollectionCard.tsx:86), and rendered a skeleton forever.'favorites'sentinel (DOWNLOAD_REASON_FAVORITES) lives in the same map and was being passed downstream as a "collection id."collectionType, so the Albums tab also pulled in playlist IDs and vice versa.isPending/isLoadingfrom the network query, which staystrueindefinitely under TanStack's defaultnetworkMode: 'online'when offline. With an emptycollectionIds, that drove the outerCardListskeleton too.Fix
offlineCollectionIds(drop the'favorites'sentinel, ignore non-numeric keys).useCollectionshook, then filter byis_albumpercollectionTypeand apply the existing text filter.isPending/isLoading/hasNextPage/isFetchingNextPageto offline-appropriate values (driven byisDoneLoadingFromDisk) when not reachable, so the outer skeleton no longer gates on the paused network query.Single file changed:
packages/mobile/src/screens/library-screen/useLibraryCollections.ts. Both the Albums and Playlists tabs share this hook, so both are fixed.Test plan
'favorites'ghost card).isPendingresolves once disk rehydration completes).npx tscandnpx eslintclean foruseLibraryCollections.ts.🤖 Generated with Claude Code