mirror of
https://github.com/Jellify-Music/App.git
synced 2026-01-05 02:19:55 -06:00
recently played now sets the queue
This commit is contained in:
@@ -23,7 +23,7 @@ export default function RecentlyPlayed(): React.JSX.Element {
|
||||
<View>
|
||||
<H2>Play it again</H2>
|
||||
<ScrollView horizontal>
|
||||
{ recentTracks && recentTracks.map((recentlyPlayedTrack) => {
|
||||
{ recentTracks && recentTracks.map((recentlyPlayedTrack, index) => {
|
||||
return (
|
||||
<Card
|
||||
caption={recentlyPlayedTrack.Name}
|
||||
@@ -34,8 +34,8 @@ export default function RecentlyPlayed(): React.JSX.Element {
|
||||
marginRight={20}
|
||||
onPress={async () => {
|
||||
await resetQueue(false);
|
||||
await addToQueue([mapDtoToTrack(apiClient!, sessionId, recentlyPlayedTrack)])
|
||||
play();
|
||||
await addToQueue(recentTracks.map((track) => mapDtoToTrack(apiClient!, sessionId, track)));
|
||||
play(index);
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -15,7 +15,7 @@ interface PlayerContext {
|
||||
showMiniplayer: boolean;
|
||||
setShowMiniplayer: React.Dispatch<SetStateAction<boolean>>;
|
||||
queue: JellifyTrack[];
|
||||
play: () => Promise<void>,
|
||||
play: (index?: number | undefined) => Promise<void>,
|
||||
pause: () => Promise<void>,
|
||||
resetQueue: (hideMiniplayer : boolean | undefined) => Promise<void>;
|
||||
addToQueue: (tracks: JellifyTrack[]) => Promise<void>;
|
||||
@@ -37,7 +37,11 @@ const PlayerContextInitializer = () => {
|
||||
|
||||
|
||||
//#region Functions
|
||||
const play = async () => {
|
||||
const play = async (index?: number | undefined) => {
|
||||
|
||||
if (index)
|
||||
TrackPlayer.skip(index)
|
||||
|
||||
TrackPlayer.play();
|
||||
|
||||
const activeTrack = await TrackPlayer.getActiveTrack() as JellifyTrack;
|
||||
@@ -117,7 +121,7 @@ export const PlayerContext = createContext<PlayerContext>({
|
||||
showMiniplayer: false,
|
||||
setShowMiniplayer: () => {},
|
||||
queue: [],
|
||||
play: async () => {},
|
||||
play: async (index?: number | undefined) => {},
|
||||
pause: async () => {},
|
||||
resetQueue: async () => {},
|
||||
addToQueue: async ([]) => {},
|
||||
|
||||
Reference in New Issue
Block a user