feat: update settings handling for pomodoro configuration
- add `UpdateSettings()` to update pomodoro configuration
- refactor client command handling to use `UpdateSettings()`
🤖
This commit is contained in:
parent
1a47c0607b
commit
1b01041a14
2 changed files with 9 additions and 5 deletions
|
@ -2,6 +2,7 @@ package pomodoro
|
|||
|
||||
import (
|
||||
"git.smsvc.net/pomodoro/GoTomato/internal/shared"
|
||||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
@ -99,3 +100,10 @@ func IsPomodoroPaused() bool {
|
|||
defer mu.Unlock() // Ensures that the mutex is unlocked after the function is done
|
||||
return shared.Message.Paused
|
||||
}
|
||||
|
||||
func UpdateSettings(settings models.PomodoroConfig) {
|
||||
if settings != (models.PomodoroConfig{}) {
|
||||
shared.Message.Settings = settings
|
||||
shared.Message.TimeLeft = settings.Work
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,11 +49,7 @@ func handleClientCommands(ws *websocket.Conn) {
|
|||
}
|
||||
case "updateSettings":
|
||||
if !pomodoro.IsPomodoroOngoing() {
|
||||
if clientCommand.Settings != (models.PomodoroConfig{}) {
|
||||
shared.Message.Settings = clientCommand.Settings
|
||||
shared.Message.TimeLeft = clientCommand.Settings.Work
|
||||
}
|
||||
|
||||
pomodoro.UpdateSettings(clientCommand.Settings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue