From 61b2f71bf353812b0d8e0d2bcd1a999fb1022842 Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Sat, 26 Oct 2024 09:15:49 +0200 Subject: [PATCH] break: rename `ServerMessage.PomodoroSettings` -> `.Settings` --- internal/pomodoro/pomodoro.go | 4 ++-- internal/shared/state.go | 12 ++++++------ internal/websocket/client_commands.go | 2 +- pkg/models/server.go | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/pomodoro/pomodoro.go b/internal/pomodoro/pomodoro.go index 5f0af99..be39e6e 100644 --- a/internal/pomodoro/pomodoro.go +++ b/internal/pomodoro/pomodoro.go @@ -29,7 +29,7 @@ func RunPomodoro() { shared.Message.Paused = false mu.Unlock() - pomodoroConfig := shared.Message.PomodoroSettings + pomodoroConfig := shared.Message.Settings for session := 1; session <= pomodoroConfig.Sessions; session++ { timer = timer.Init() @@ -66,7 +66,7 @@ func RunPomodoro() { shared.Message.Mode = "Idle" shared.Message.Session = 0 - shared.Message.TimeLeft = shared.Message.PomodoroSettings.Work + shared.Message.TimeLeft = shared.Message.Settings.Work } func ResetPomodoro() { diff --git a/internal/shared/state.go b/internal/shared/state.go index 04c6949..1f8c670 100644 --- a/internal/shared/state.go +++ b/internal/shared/state.go @@ -5,12 +5,12 @@ import ( ) var Message = models.ServerMessage{ - Mode: "Idle", - PomodoroSettings: DefaultPomodoroConfig, - Session: 0, - TimeLeft: DefaultPomodoroConfig.Work, - Ongoing: false, - Paused: false, + Mode: "Idle", + Settings: DefaultPomodoroConfig, + Session: 0, + TimeLeft: DefaultPomodoroConfig.Work, + Ongoing: false, + Paused: false, } var PomodoroPassword string diff --git a/internal/websocket/client_commands.go b/internal/websocket/client_commands.go index 4a0cbd1..88535e4 100644 --- a/internal/websocket/client_commands.go +++ b/internal/websocket/client_commands.go @@ -50,7 +50,7 @@ func handleClientCommands(ws *websocket.Conn) { case "updateSettings": if !pomodoro.IsPomodoroOngoing() { if clientCommand.PomodoroSettings != (models.GoTomatoPomodoroConfig{}) { - shared.Message.PomodoroSettings = clientCommand.PomodoroSettings + shared.Message.Settings = clientCommand.PomodoroSettings shared.Message.TimeLeft = clientCommand.PomodoroSettings.Work } diff --git a/pkg/models/server.go b/pkg/models/server.go index c95d5f2..674eeba 100644 --- a/pkg/models/server.go +++ b/pkg/models/server.go @@ -2,11 +2,11 @@ package models // ServerMessage represents the data sent to the client via WebSocket. type ServerMessage struct { - Mode string `json:"mode"` // "Idle", "Work", "ShortBreak", "LongBreak" or "End" - PomodoroSettings GoTomatoPomodoroConfig `json:"settings"` // The currrent pomodoro settings - Session int `json:"session"` // Current session number - TimeLeft int `json:"time_left"` // Remaining time in seconds - Ongoing bool `json:"ongoing"` // Ongoing pomodoro - Paused bool `json:"paused"` // Is timer paused - GoTomatoVersion string `json:"version"` // Version of the server + Mode string `json:"mode"` // "Idle", "Work", "ShortBreak", "LongBreak" or "End" + Settings GoTomatoPomodoroConfig `json:"settings"` // The currrent pomodoro settings + Session int `json:"session"` // Current session number + TimeLeft int `json:"time_left"` // Remaining time in seconds + Ongoing bool `json:"ongoing"` // Ongoing pomodoro + Paused bool `json:"paused"` // Is timer paused + GoTomatoVersion string `json:"version"` // Version of the server }