From 0f8fde3143984b10deb075f4ee524704da90666e Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Mon, 28 Oct 2024 07:56:37 +0100 Subject: [PATCH] fix: update GoTomato model field names adjust field names due to breaking changes in GoTomato v0.0.4 --- go.sum | 2 -- internal/frontend/keyhandler.go | 2 +- internal/frontend/notification.go | 8 ++++---- internal/frontend/terminal.go | 8 ++++---- internal/websocket/send.go | 8 ++++---- pkg/models/configfile.go | 6 +++--- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/go.sum b/go.sum index ef4695b..6d09809 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ atomicgo.dev/cursor v0.2.0 h1:H6XN5alUJ52FZZUkI7AlJbUc1aW38GWZalpYRPpoPOw= atomicgo.dev/cursor v0.2.0/go.mod h1:Lr4ZJB3U7DfPPOkbH7/6TOtJ4vFGHlgj1nc+n900IpU= atomicgo.dev/keyboard v0.2.9 h1:tOsIid3nlPLZ3lwgG8KZMp/SFmr7P0ssEN5JUsm78K8= atomicgo.dev/keyboard v0.2.9/go.mod h1:BC4w9g00XkxH/f1HXhW2sXmJFOCWbKn9xrOunSFtExQ= -git.smsvc.net/pomodoro/GoTomato v0.0.3 h1:9tYd26YM52CT1g/eNFrc14sSrGQUELuIVh6KT91DpII= -git.smsvc.net/pomodoro/GoTomato v0.0.3/go.mod h1:TV6+3bYjwc+kJ7I60H9YSd7BdBBzPnisx/MRnBbEeDk= git.smsvc.net/pomodoro/GoTomato v0.0.4 h1:+pCbPXUMtPteQilMe3QNo6fl67kB9gO6C/g0sNj1zck= git.smsvc.net/pomodoro/GoTomato v0.0.4/go.mod h1:rNFUjjBMKplygWYbgErWd4cD8JQ66h0KyiK54cGktJo= github.com/MarvinJWendt/testza v0.1.0/go.mod h1:7AxNvlfeHP7Z/hDQ5JtE3OKYT3XFUeLCDE2DQninSqs= diff --git a/internal/frontend/keyhandler.go b/internal/frontend/keyhandler.go index 0c0ed45..49bec97 100644 --- a/internal/frontend/keyhandler.go +++ b/internal/frontend/keyhandler.go @@ -36,7 +36,7 @@ func keyhandler(conn *ws.Conn, config ChronoTomato.Config, message *GoTomato.Ser case "s": websocket.SendCmd(conn, config.Password, "stop") case "r": - if config.PomodoroConfig != (GoTomato.GoTomatoPomodoroConfig{}) { + if config.PomodoroConfig != (GoTomato.PomodoroConfig{}) { websocket.Send_updateSettings(conn, config.Password, config.PomodoroConfig) } case "q": diff --git a/internal/frontend/notification.go b/internal/frontend/notification.go index 250c5db..bbf53bf 100644 --- a/internal/frontend/notification.go +++ b/internal/frontend/notification.go @@ -16,17 +16,17 @@ func desktopNotifications(pomodoro GoTomato.ServerMessage) { mode := pomodoro.Mode session := pomodoro.Session - sessions := pomodoro.PomodoroSettings.Sessions + sessions := pomodoro.Settings.Sessions switch mode { case "Work": - duration = pomodoro.PomodoroSettings.Work + duration = pomodoro.Settings.Work notification = fmt.Sprintf("Session %d/%d: %s %0.f minutes", session, sessions, mode, float32(duration)/60) case "ShortBreak": - duration = pomodoro.PomodoroSettings.ShortBreak + duration = pomodoro.Settings.ShortBreak notification = fmt.Sprintf("Session %d/%d: Take a %0.f minute break", session, sessions, float32(duration)/60) case "LongBreak": - duration = pomodoro.PomodoroSettings.LongBreak + duration = pomodoro.Settings.LongBreak notification = fmt.Sprintf("Long Break: Take a %0.f minute break", float32(duration)/60) case "End": duration = 0 diff --git a/internal/frontend/terminal.go b/internal/frontend/terminal.go index 70d9deb..bac0907 100644 --- a/internal/frontend/terminal.go +++ b/internal/frontend/terminal.go @@ -18,9 +18,9 @@ func terminalOutput(pomodoro GoTomato.ServerMessage) { // header color.Blue("Work: %d ◊ Break: %d ◊ Longbreak: %d\n\n", - pomodoro.PomodoroSettings.Work/60, - pomodoro.PomodoroSettings.ShortBreak/60, - pomodoro.PomodoroSettings.LongBreak/60, + pomodoro.Settings.Work/60, + pomodoro.Settings.ShortBreak/60, + pomodoro.Settings.LongBreak/60, ) //body @@ -41,7 +41,7 @@ func terminalOutput(pomodoro GoTomato.ServerMessage) { fmt.Printf("Session: %d/%d\n", pomodoro.Session, - pomodoro.PomodoroSettings.Sessions, + pomodoro.Settings.Sessions, ) fmt.Printf("%s %s\n", modePrefix, pomodoro.Mode) fmt.Printf(timerOutput) diff --git a/internal/websocket/send.go b/internal/websocket/send.go index 90df844..942b4b6 100644 --- a/internal/websocket/send.go +++ b/internal/websocket/send.go @@ -31,11 +31,11 @@ func SendCmd(conn *websocket.Conn, pwd string, cmd string) { sendClientCommand(conn, message) } -func Send_updateSettings(conn *websocket.Conn, pwd string, settings GoTomato.GoTomatoPomodoroConfig) { +func Send_updateSettings(conn *websocket.Conn, pwd string, settings GoTomato.PomodoroConfig) { message := GoTomato.ClientCommand{ - Command: "updateSettings", - Password: pwd, - PomodoroSettings: settings, + Command: "updateSettings", + Password: pwd, + Settings: settings, } sendClientCommand(conn, message) diff --git a/pkg/models/configfile.go b/pkg/models/configfile.go index b8ea721..4e824db 100644 --- a/pkg/models/configfile.go +++ b/pkg/models/configfile.go @@ -3,7 +3,7 @@ package models import GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models" type Config struct { - URL string `yaml:"url"` - Password string `yaml:"password"` - PomodoroConfig GoTomato.GoTomatoPomodoroConfig `yaml:"config"` + URL string `yaml:"url"` + Password string `yaml:"password"` + PomodoroConfig GoTomato.PomodoroConfig `yaml:"config"` }