diff --git a/README.md b/README.md index 2b4316c..c97da81 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ All fields are mandatory and may not be ommitted. The server periodically (every second) sends JSON-encoded messages to all connected clients to update them on the current state of the Pomodoro session. These messages contain the following fields: - mode: Indicates the current phase of the Pomodoro session ("Work", "ShortBreak", "LongBreak", "End" or "Idle"). + - "End" is send only once, after all sessions are finished - settings: Contains the current Pomodoro settings: - work: Length of the work session in seconds (e.g., 1500 for 25 minutes). - shortBreak: Length of the short break in seconds (e.g., 300 for 5 minutes). diff --git a/internal/pomodoro/pomodoro.go b/internal/pomodoro/pomodoro.go index 9d9defc..d0a9326 100644 --- a/internal/pomodoro/pomodoro.go +++ b/internal/pomodoro/pomodoro.go @@ -3,6 +3,7 @@ package pomodoro import ( "git.smsvc.net/pomodoro/GoTomato/internal/shared" "sync" + "time" ) var pomodoroResetChannel = make(chan bool, 1) @@ -40,10 +41,16 @@ func RunPomodoro() { shared.Message.Mode = "End" } + time.Sleep(time.Second) + mu.Lock() shared.Message.Ongoing = false shared.Message.Paused = false mu.Unlock() + + shared.Message.Mode = "Idle" + shared.Message.Session = 0 + shared.Message.TimeLeft = shared.Message.PomodoroSettings.Work } // Stops and resets the running Pomodoro