From eb14e9a17e5789eb50c3668d7052cccdf2dee601 Mon Sep 17 00:00:00 2001 From: Violet Caulfield <42452695+anultravioletaurora@users.noreply.github.com> Date: Wed, 5 Nov 2025 16:51:26 -0600 Subject: [PATCH] cleaning up loadQueue function Removing the need for a "downloadedTracks" parameter and instead just fetching from the audiocache fix carplay not showing up --- src/components/jellify.tsx | 1 + src/providers/Player/functions/queue.ts | 10 ++++------ src/providers/Player/hooks/mutations.ts | 14 +++++--------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/components/jellify.tsx b/src/components/jellify.tsx index fd295ad1..7755e1ae 100644 --- a/src/components/jellify.tsx +++ b/src/components/jellify.tsx @@ -77,6 +77,7 @@ function App(): React.JSX.Element { return ( + diff --git a/src/providers/Player/functions/queue.ts b/src/providers/Player/functions/queue.ts index 6fc81f12..207bed1a 100644 --- a/src/providers/Player/functions/queue.ts +++ b/src/providers/Player/functions/queue.ts @@ -9,10 +9,7 @@ import JellifyTrack from '../../../types/JellifyTrack' import { getCurrentTrack } from '.' import { JellifyDownload } from '../../../types/JellifyDownload' import { usePlayerQueueStore } from '../../../stores/player/queue' - -type LoadQueueOperation = QueueMutation & { - downloadedTracks: JellifyDownload[] | undefined -} +import { getAudioCache } from '../../../api/mutations/download/offlineModeUtils' type LoadQueueResult = { finalStartIndex: number @@ -27,8 +24,7 @@ export async function loadQueue({ api, deviceProfile, networkStatus = networkStatusTypes.ONLINE, - downloadedTracks, -}: LoadQueueOperation): Promise { +}: QueueMutation): Promise { usePlayerQueueStore.getState().setQueueRef(queueRef) usePlayerQueueStore.getState().setShuffled(shuffled) @@ -37,6 +33,8 @@ export async function loadQueue({ // Get the item at the start index const startingTrack = tracklist[startIndex] + const downloadedTracks = getAudioCache() + const availableAudioItems = filterTracksOnNetworkStatus( networkStatus as networkStatusTypes, tracklist, diff --git a/src/providers/Player/hooks/mutations.ts b/src/providers/Player/hooks/mutations.ts index 1b70a9c9..ae759fd1 100644 --- a/src/providers/Player/hooks/mutations.ts +++ b/src/providers/Player/hooks/mutations.ts @@ -14,12 +14,12 @@ import { useRemoteMediaClient } from 'react-native-google-cast' import { NativeStackNavigationProp } from '@react-navigation/native-stack' import { RootStackParamList } from '../../../screens/types' import { useNavigation } from '@react-navigation/native' -import { useAllDownloadedTracks } from '../../../api/queries/download' import useHapticFeedback from '../../../hooks/use-haptic-feedback' import { queryClient } from '../../../constants/query-client' import { REPEAT_MODE_QUERY_KEY } from '../constants/query-keys' import { usePlayerQueueStore } from '../../../stores/player/queue' import { useCallback } from 'react' +import { getAudioCache } from '../../../api/mutations/download/offlineModeUtils' /** * A mutation to handle starting playback @@ -151,15 +151,13 @@ const useSeekBy = () => { } export const useAddToQueue = () => { - const downloadedTracks = useAllDownloadedTracks().data - const trigger = useHapticFeedback() return useMutation({ mutationFn: (variables: AddToQueueMutation) => variables.queuingType === QueuingType.PlayingNext - ? playNextInQueue({ ...variables, downloadedTracks }) - : playLaterInQueue({ ...variables, downloadedTracks }), + ? playNextInQueue({ ...variables, downloadedTracks: getAudioCache() }) + : playLaterInQueue({ ...variables, downloadedTracks: getAudioCache() }), onSuccess: (_: void, { queuingType }: AddToQueueMutation) => { trigger('notificationSuccess') console.debug( @@ -198,15 +196,13 @@ export const useLoadNewQueue = () => { const remoteClient = useRemoteMediaClient() const navigation = useNavigation>() - const { data: downloadedTracks } = useAllDownloadedTracks() - const trigger = useHapticFeedback() return useCallback( async (variables: QueueMutation) => { trigger('impactLight') await TrackPlayer.pause() - const { finalStartIndex, tracks } = await loadQueue({ ...variables, downloadedTracks }) + const { finalStartIndex, tracks } = await loadQueue({ ...variables }) usePlayerQueueStore.getState().setCurrentIndex(finalStartIndex) @@ -225,7 +221,7 @@ export const useLoadNewQueue = () => { usePlayerQueueStore.getState().setQueue(tracks) usePlayerQueueStore.getState().setCurrentTrack(tracks[finalStartIndex]) }, - [isCasting, remoteClient, navigation, downloadedTracks, trigger, usePlayerQueueStore], + [isCasting, remoteClient, navigation, trigger, usePlayerQueueStore], ) }