Nutlope / notesGPT

Record voice notes & transcribe, summarize, and get tasks
https://usenotesgpt.com
MIT License
1.73k stars 268 forks source link

time counting error #10

Closed fjun99 closed 8 months ago

fjun99 commented 8 months ago

Great project!

There is a time counting error.

When it is 00:59, the next second will show as 2:00.

When it is 01:59, the next second will show as 4:00.

We may choose to use totalSeconds instead of minutes and seconds.

const [totalSeconds, setTotalSeconds] = useState(0);
useEffect(() => {
  let interval: NodeJS.Timeout;

  if (isRunning) {
    interval = setInterval(() => {
      setTotalSeconds((prevTotalSeconds) => prevTotalSeconds + 1);
    }, 1000);
  }

  return () => {
    if (interval) {
      clearInterval(interval);
    }
  };
}, [isRunning]);
function formatTime(time: number): string {
  return time < 10 ? `0${time}` : `${time}`;
}

...
{formatTime(Math.floor(totalSeconds / 60))}:{formatTime(totalSeconds % 60)}

A pull request submitted.

fjun99 commented 8 months ago

notes: NotesGPT at https://usenotesgpt.com/record displays the correct time. However, in a local deployment on a MacBook, I consistently encounter this error.