break: add updateSettings
command to modify Pomodoro settings
- add `updateSettings` command to modify Pomodoro configuration
- remove ability to set Pomodoro configuration in `start` command
- update demo client
- update README
🤖
This commit is contained in:
parent
a0dba673a2
commit
cb6616f400
5 changed files with 75 additions and 59 deletions
|
@ -9,8 +9,6 @@ import (
|
|||
"log"
|
||||
)
|
||||
|
||||
var pomodoroConfig = shared.DefaultPomodoroConfig
|
||||
|
||||
// handleClientCommands listens for commands from WebSocket clients
|
||||
func handleClientCommands(ws *websocket.Conn) {
|
||||
for {
|
||||
|
@ -35,10 +33,7 @@ func handleClientCommands(ws *websocket.Conn) {
|
|||
switch clientCommand.Command {
|
||||
case "start":
|
||||
if !pomodoro.IsPomodoroOngoing() {
|
||||
if clientCommand.Config != shared.UnsetPomodoroConfig {
|
||||
pomodoroConfig = clientCommand.Config
|
||||
}
|
||||
go pomodoro.RunPomodoro(pomodoroConfig) // Start the timer with the list of clients
|
||||
go pomodoro.RunPomodoro() // Start the timer with the list of clients
|
||||
}
|
||||
case "stop":
|
||||
if pomodoro.IsPomodoroOngoing() {
|
||||
|
@ -52,6 +47,14 @@ func handleClientCommands(ws *websocket.Conn) {
|
|||
if pomodoro.IsPomodoroOngoing() && pomodoro.IsPomodoroPaused() {
|
||||
pomodoro.ResumePomodoro() // Resume the timer
|
||||
}
|
||||
case "updateSettings":
|
||||
if !pomodoro.IsPomodoroOngoing() {
|
||||
if clientCommand.PomodoroSettings != shared.UnsetPomodoroConfig {
|
||||
shared.Message.PomodoroSettings = clientCommand.PomodoroSettings
|
||||
shared.Message.TimeLeft = clientCommand.PomodoroSettings.Work
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue