diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index a8dd0f9..7fa83b9 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,4 @@ -import { Suspense, useState } from 'react'; +import { Suspense, useRef, useState } from 'react'; import { UseQueryResult, useQuery } from '@tanstack/react-query'; import axios from 'axios'; @@ -18,12 +18,16 @@ function App() { const videoSource = queue[queuePosition]; const addToQueue = (url: string) => setQueue((prev) => [...prev, url]); - const skipToNext = () => setQueuePosition((prev) => ++prev % queue.length); + const skipToPrevious = () => + setQueuePosition((prev) => (prev - 1 < 0 ? queue.length - 1 : prev - 1)); + const skipToNext = () => + setQueuePosition((prev) => (prev + 1) % queue.length); return (