mirror of
https://github.com/Jellify-Music/App.git
synced 2026-03-17 18:51:24 -05:00
* fix: update sort icon name and label in ArtistTabBar * fix: optimize image URL generation and improve performance in Playlists and Tracks components * homescreen improvements * deduplicate tracks in FrequentlyPlayedTracks and RecentlyPlayed components * enhance storage management with versioning and slimmed track persistence * refactor HorizontalCardList to allow customizable estimatedItemSize * update sort button label in ArtistTabBar for clarity * refactor media info fetching and improve search debounce logic * refactor navigation parameters in artist and track components for simplicity * refactor PlayPauseButton to manage optimistic UI state and improve playback handling * Cut queue remap churn, speed lyric lookup, clean cast listener cleanup, and avoid redundant HEADs on downloads * Revert "Cut queue remap churn, speed lyric lookup, clean cast listener cleanup, and avoid redundant HEADs on downloads" This reverts commit1c63b748b6. * Cut queue remap churn, speed lyric lookup, clean cast listener cleanup, and avoid redundant HEADs on downloads * Revert "Cut queue remap churn, speed lyric lookup, clean cast listener cleanup, and avoid redundant HEADs on downloads" This reverts commitf9e0e82e57. * Reapply "Cut queue remap churn, speed lyric lookup, clean cast listener cleanup, and avoid redundant HEADs on downloads" This reverts commit6710d3404c. * Update project configuration: refine build phases, adjust code signing identity, and format flags * Fix TypeScript errors in Search component and improve playback state handler in Player queries * Refactor ItemRow component to accept queueName prop and update queue handling * lot's o fixes to item cards and item rows * memoize tracks component * fix jest * simplify navigation in FrequentArtists, FrequentlyPlayedTracks, RecentArtists, and RecentlyPlayed components * Update axios version and enhance image handling options in components * Enhance ItemImage component with imageOptions for better image handling in PlayerHeader and Miniplayer * moves buffers to player config --------- Co-authored-by: Violet Caulfield <42452695+anultravioletaurora@users.noreply.github.com> Co-authored-by: Violet Caulfield <violet@cosmonautical.cloud>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { useEffect } from 'react'
|
|
import { create } from 'zustand'
|
|
import { devtools, persist } from 'zustand/middleware'
|
|
import { useCastState, CastState } from 'react-native-google-cast'
|
|
import TrackPlayer from 'react-native-track-player'
|
|
|
|
export enum PlayerEngine {
|
|
GOOGLE_CAST = 'google_cast',
|
|
CARPLAY = 'carplay',
|
|
REACT_NATIVE_TRACK_PLAYER = 'react_native_track_player',
|
|
}
|
|
|
|
type playerEngineStore = {
|
|
playerEngineData: PlayerEngine
|
|
setPlayerEngineData: (data: PlayerEngine) => void
|
|
}
|
|
|
|
const usePlayerEngineStore = create<playerEngineStore>()(
|
|
devtools(
|
|
persist(
|
|
(set) => ({
|
|
playerEngineData: PlayerEngine.REACT_NATIVE_TRACK_PLAYER,
|
|
setPlayerEngineData: (data: PlayerEngine) => set({ playerEngineData: data }),
|
|
}),
|
|
{
|
|
name: 'player-engine-storage',
|
|
},
|
|
),
|
|
),
|
|
)
|
|
|
|
export const useSelectPlayerEngine = () => {
|
|
const setPlayerEngineData = usePlayerEngineStore((state) => state.setPlayerEngineData)
|
|
const castState = useCastState()
|
|
|
|
useEffect(() => {
|
|
if (castState === CastState.CONNECTED) {
|
|
setPlayerEngineData(PlayerEngine.GOOGLE_CAST)
|
|
void TrackPlayer.pause() // pause the track player to avoid conflicts
|
|
return
|
|
}
|
|
setPlayerEngineData(PlayerEngine.REACT_NATIVE_TRACK_PLAYER)
|
|
}, [castState, setPlayerEngineData])
|
|
}
|
|
|
|
export default usePlayerEngineStore
|