break: add updateSettings
command to modify Pomodoro settings
- add `updateSettings` command to modify Pomodoro configuration
- remove ability to set Pomodoro configuration in `start` command
- update demo client
- update README
🤖
This commit is contained in:
parent
a0dba673a2
commit
cb6616f400
5 changed files with 75 additions and 59 deletions
|
@ -2,7 +2,7 @@ package pomodoro
|
|||
|
||||
import (
|
||||
"git.smsvc.net/pomodoro/GoTomato/internal/shared"
|
||||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
// "git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
@ -13,28 +13,28 @@ 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(config models.GoTomatoPomodoroConfig) {
|
||||
func RunPomodoro() {
|
||||
mu.Lock()
|
||||
shared.Message.Ongoing = true
|
||||
shared.Message.Paused = false
|
||||
mu.Unlock()
|
||||
|
||||
shared.Message.PomodoroSettings = config
|
||||
pomodoroConfig := shared.Message.PomodoroSettings
|
||||
|
||||
for session := 1; session <= config.Sessions; session++ {
|
||||
for session := 1; session <= pomodoroConfig.Sessions; session++ {
|
||||
shared.Message.Session = session
|
||||
shared.Message.Mode = "Work"
|
||||
if !startTimer(config.Work) {
|
||||
if !startTimer(pomodoroConfig.Work) {
|
||||
break
|
||||
}
|
||||
if session == config.Sessions {
|
||||
if session == pomodoroConfig.Sessions {
|
||||
shared.Message.Mode = "LongBreak"
|
||||
if !startTimer(config.LongBreak) {
|
||||
if !startTimer(pomodoroConfig.LongBreak) {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
shared.Message.Mode = "ShortBreak"
|
||||
if !startTimer(config.ShortBreak) {
|
||||
if !startTimer(pomodoroConfig.ShortBreak) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue