fix: send correct server message on pomodoro end
- replace manual state reset with a dedicated ResetToDefault function
- remove locking mechanism during state updates
🤖
This commit is contained in:
parent
b7d03aa1d8
commit
bf2685a055
2 changed files with 13 additions and 21 deletions
|
@ -40,26 +40,14 @@ func RunPomodoro(config models.GoTomatoPomodoroConfig) {
|
|||
}
|
||||
}
|
||||
|
||||
mu.Lock()
|
||||
shared.Message.Ongoing = false
|
||||
mu.Unlock()
|
||||
shared.Message = shared.ResetToDefault()
|
||||
}
|
||||
|
||||
// ResetPomodoro resets the running Pomodoro timer.
|
||||
func ResetPomodoro() {
|
||||
// Send a reset signal to stop any running timers
|
||||
pomodoroResetChannel <- true
|
||||
|
||||
mu.Lock()
|
||||
shared.Message.Ongoing = false
|
||||
shared.Message.Paused = false
|
||||
mu.Unlock()
|
||||
|
||||
// Reset message
|
||||
shared.Message.Mode = ""
|
||||
shared.Message.Session = 0
|
||||
shared.Message.TotalSession = 0
|
||||
shared.Message.TimeLeft = 0
|
||||
shared.Message = shared.ResetToDefault()
|
||||
}
|
||||
|
||||
func PausePomodoro() {
|
||||
|
|
|
@ -4,7 +4,10 @@ import (
|
|||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
)
|
||||
|
||||
var Message = models.ServerMessage{
|
||||
var Message = ResetToDefault()
|
||||
|
||||
func ResetToDefault() models.ServerMessage {
|
||||
return models.ServerMessage{
|
||||
Mode: "",
|
||||
Session: 0,
|
||||
TotalSession: 0,
|
||||
|
@ -12,3 +15,4 @@ var Message = models.ServerMessage{
|
|||
Ongoing: false,
|
||||
Paused: false,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue