import { atom } from 'jotai' import { State, Track } from 'react-native-track-player' import equal from 'fast-deep-equal' type OptionalTrack = Track | undefined const currentTrack = atom(undefined) export const currentTrackAtom = atom( get => get(currentTrack), (get, set, value) => { if (!equal(get(currentTrack), value)) { set(currentTrack, value) } }, ) type OptionalString = string | undefined const currentQueueName = atom(undefined) export const currentQueueNameAtom = atom( get => get(currentQueueName), (get, set, value) => { if (get(currentQueueName) !== value) { set(currentQueueName, value) } }, ) const playerState = atom(State.None) export const playerStateAtom = atom( get => get(playerState), (get, set, value) => { if (get(playerState) !== value) { set(playerState, value) } }, )