diff --git a/front/views/PlayView.tsx b/front/views/PlayView.tsx index 2648052..9f5058f 100644 --- a/front/views/PlayView.tsx +++ b/front/views/PlayView.tsx @@ -77,7 +77,7 @@ const PlayView = ({ songId, type, route }: RouteProps) => { const webSocket = useRef(); const [paused, setPause] = useState(true); const stopwatch = useStopwatch(); - const [time, setTime] = useState(0); + const time = useRef(0); const [partitionRendered, setPartitionRendered] = useState(false); // Used to know when partitionview can render const [score, setScore] = useState(0); // Between 0 and 100 const fadeAnim = useRef(new Animated.Value(0)).current; @@ -236,7 +236,7 @@ const PlayView = ({ songId, type, route }: RouteProps) => { useEffect(() => { ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE).catch(() => {}); const interval = setInterval(() => { - setTime(() => getElapsedTime()); // Countdown + time.current = getElapsedTime(); // Countdown }, 1); return () => { @@ -289,7 +289,7 @@ const PlayView = ({ songId, type, route }: RouteProps) => { ) => { }} /> - {time < 0 + {time.current < 0 ? paused ? '0:00' - : Math.floor((time % 60000) / 1000) + : Math.floor((time.current % 60000) / 1000) .toFixed(0) .toString() - : `${Math.floor(time / 60000)}:${Math.floor( - (time % 60000) / 1000 + : `${Math.floor(time.current / 60000)}:${Math.floor( + (time.current % 60000) / 1000 ) .toFixed(0) .toString()