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 = shared.ResetToDefault()
|
||||||
shared.Message.Ongoing = false
|
|
||||||
mu.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetPomodoro resets the running Pomodoro timer.
|
// ResetPomodoro resets the running Pomodoro timer.
|
||||||
func ResetPomodoro() {
|
func ResetPomodoro() {
|
||||||
// Send a reset signal to stop any running timers
|
// Send a reset signal to stop any running timers
|
||||||
pomodoroResetChannel <- true
|
pomodoroResetChannel <- true
|
||||||
|
shared.Message = shared.ResetToDefault()
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func PausePomodoro() {
|
func PausePomodoro() {
|
||||||
|
|
|
@ -4,11 +4,15 @@ import (
|
||||||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Message = models.ServerMessage{
|
var Message = ResetToDefault()
|
||||||
Mode: "",
|
|
||||||
Session: 0,
|
func ResetToDefault() models.ServerMessage {
|
||||||
TotalSession: 0,
|
return models.ServerMessage{
|
||||||
TimeLeft: 0,
|
Mode: "",
|
||||||
Ongoing: false,
|
Session: 0,
|
||||||
Paused: false,
|
TotalSession: 0,
|
||||||
|
TimeLeft: 0,
|
||||||
|
Ongoing: false,
|
||||||
|
Paused: false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue