break: update ServerMessage model

- rename MaxSession to TotalSession (and JSON struct tags)

🤖
This commit is contained in:
Sebastian Mark 2024-10-20 23:20:23 +02:00
parent 2ac1aecba1
commit f183686272
5 changed files with 23 additions and 23 deletions

View file

@ -52,10 +52,10 @@ func ResetPomodoro(clients map[*websocket.Conn]*models.Client) {
// Broadcast the reset message to all clients
broadcast.BroadcastMessage(clients, models.ServerMessage{
Mode: "none",
Session: 0,
MaxSession: 0,
TimeLeft: 0,
Mode: "none",
Session: 0,
TotalSession: 0,
TimeLeft: 0,
})
// Send a reset signal to stop any running timers

View file

@ -8,7 +8,7 @@ import (
)
// startTimer runs the countdown and broadcasts every second.
func startTimer(clients map[*websocket.Conn]*models.Client, remainingSeconds int, mode string, session int, sessions int) bool {
func startTimer(clients map[*websocket.Conn]*models.Client, remainingSeconds int, mode string, session int, totalSessions int) bool {
for remainingSeconds > 0 {
select {
case <-pomodoroResetChannel:
@ -21,10 +21,10 @@ func startTimer(clients map[*websocket.Conn]*models.Client, remainingSeconds int
// Broadcast the current state to all clients
if !IsPomodoroPaused() {
broadcast.BroadcastMessage(clients, models.ServerMessage{
Mode: mode,
Session: session,
MaxSession: sessions,
TimeLeft: remainingSeconds,
Mode: mode,
Session: session,
TotalSession: totalSessions,
TimeLeft: remainingSeconds,
})
time.Sleep(time.Second)
remainingSeconds--
@ -34,10 +34,10 @@ func startTimer(clients map[*websocket.Conn]*models.Client, remainingSeconds int
// Final broadcast when time reaches zero
broadcast.BroadcastMessage(clients, models.ServerMessage{
Mode: mode,
Session: session,
MaxSession: sessions,
TimeLeft: 0,
Mode: mode,
Session: session,
TotalSession: totalSessions,
TimeLeft: 0,
})
return true