feat: simplify pomodoro functions by removing client parameter
- remove clients parameter from RunPomodoro function
- update startTimer to no longer require clients parameter
- modify ResetPomodoro to eliminate clients parameter
- adjust client_commands to reflect changes in function signatures
🤖
This commit is contained in:
parent
9615d4d449
commit
234f3c17dc
3 changed files with 8 additions and 11 deletions
|
@ -3,7 +3,6 @@ package pomodoro
|
|||
import (
|
||||
"git.smsvc.net/pomodoro/GoTomato/internal/broadcast"
|
||||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
"github.com/gorilla/websocket"
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
@ -14,7 +13,7 @@ var pomodoroResumeChannel = make(chan bool, 1)
|
|||
var mu sync.Mutex // to synchronize access to shared state
|
||||
|
||||
// RunPomodoro iterates the Pomodoro work/break sessions.
|
||||
func RunPomodoro(clients map[*websocket.Conn]*models.Client, config models.GoTomatoPomodoroConfig) {
|
||||
func RunPomodoro(config models.GoTomatoPomodoroConfig) {
|
||||
mu.Lock()
|
||||
broadcast.Message.Ongoing = true
|
||||
broadcast.Message.Paused = false
|
||||
|
@ -24,15 +23,15 @@ func RunPomodoro(clients map[*websocket.Conn]*models.Client, config models.GoTom
|
|||
|
||||
for session := 1; session <= config.Sessions; session++ {
|
||||
broadcast.Message.Session = session
|
||||
if !startTimer(clients, config.Work, "Work") {
|
||||
if !startTimer(config.Work, "Work") {
|
||||
break
|
||||
}
|
||||
if session == config.Sessions {
|
||||
if !startTimer(clients, config.LongBreak, "LongBreak") {
|
||||
if !startTimer(config.LongBreak, "LongBreak") {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
if !startTimer(clients, config.ShortBreak, "ShortBreak") {
|
||||
if !startTimer(config.ShortBreak, "ShortBreak") {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +43,7 @@ func RunPomodoro(clients map[*websocket.Conn]*models.Client, config models.GoTom
|
|||
}
|
||||
|
||||
// ResetPomodoro resets the running Pomodoro timer.
|
||||
func ResetPomodoro(clients map[*websocket.Conn]*models.Client) {
|
||||
func ResetPomodoro() {
|
||||
// Send a reset signal to stop any running timers
|
||||
pomodoroResetChannel <- true
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue