From b7d03aa1d8f35e095ce4f9c48ae01e8dd2477e5f Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Mon, 21 Oct 2024 13:14:26 +0200 Subject: [PATCH] break: empty Message.Mode when no pomodoro ongoing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - change "none" to an empty string for the mode field - update README to reflect the new mode representation - ensure consistency across session end/reset and welcome messages 🤖 --- README.md | 6 +++--- internal/pomodoro/pomodoro.go | 2 +- internal/shared/state.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a7c41f3..955b001 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Example: The server periodically (every second) sends JSON-encoded messages to all connected clients to update them on the current state of the Pomodoro session. These messages contain the following fields: -- mode: Indicates the current phase of the Pomodoro session ("Work", "ShortBreak", "LongBreak", or "none" if no session is running). +- mode: Indicates the current phase of the Pomodoro session ("Work", "ShortBreak", "LongBreak", or empty if no session is running). - session: The current session number (e.g., 1 for the first work session). - total_sessions: The total number of sessions for the current Pomodoro cycle (e.g., 4 if the cycle consists of 4 work/break sessions). - time_left: The remaining time for the current mode, in seconds (e.g., 900 for 15 minutes). @@ -62,11 +62,11 @@ These messages contain the following fields: | Message Type | Example | | --------------------- | --------------------------------------------------- | -| Welcome Message | `{"mode": "none", "session":0, "total_sessions":0, "time_left":0, "ongoing": false, "paused": false}` | +| Welcome Message | `{"mode": "", "session":0, "total_sessions":0, "time_left":0, "ongoing": false, "paused": false}` | | Session Running | `{"mode": "Work", "session": 1, "total_sessions": 4, "time_left": 900, "ongoing": true, "paused": false}` | | Session Running | `{"mode": "ShortBreak", "session": 2, "total_sessions": 4, "time_left": 50, "ongoing": true, "paused": false}` | | Session Paused | `{"mode": "Work", "session": 2, "total_sessions": 4, "time_left": 456, "ongoing": true, "paused": true}` | -| Session End/Reset | `{"mode": "none", "session": 0, "total_sessions": 0, "time_left": 0, "ongoing": false, "paused": false}` | +| Session End/Reset | `{"mode": "", "session": 0, "total_sessions": 0, "time_left": 0, "ongoing": false, "paused": false}` | ## Testing diff --git a/internal/pomodoro/pomodoro.go b/internal/pomodoro/pomodoro.go index c5e927e..2c69b65 100644 --- a/internal/pomodoro/pomodoro.go +++ b/internal/pomodoro/pomodoro.go @@ -56,7 +56,7 @@ func ResetPomodoro() { mu.Unlock() // Reset message - shared.Message.Mode = "none" + shared.Message.Mode = "" shared.Message.Session = 0 shared.Message.TotalSession = 0 shared.Message.TimeLeft = 0 diff --git a/internal/shared/state.go b/internal/shared/state.go index 26ff2d6..3c0ddec 100644 --- a/internal/shared/state.go +++ b/internal/shared/state.go @@ -5,7 +5,7 @@ import ( ) var Message = models.ServerMessage{ - Mode: "none", + Mode: "", Session: 0, TotalSession: 0, TimeLeft: 0,