refactor: remove drawInfo from UpdateSession
This is migrated to the Run method. This commit solves the issue that the desktop notification goes off when Pominal is started.
This commit is contained in:
parent
1be999c8b6
commit
19b599e341
1 changed files with 12 additions and 5 deletions
17
pominal.go
17
pominal.go
|
@ -75,7 +75,8 @@ func NewPominal(w, s, l float64, m int) Pominal {
|
|||
func (p *Pominal) Run(infoUI, timerUI *tview.TextView) {
|
||||
|
||||
p.stopChan = make(chan struct{})
|
||||
p.UpdateSession(infoUI)
|
||||
p.UpdateSession()
|
||||
drawInfo(infoUI, p.cycle, p.workSession, p.maxWorkSessions, p.label)
|
||||
t := time.NewTicker(1 * time.Second)
|
||||
|
||||
infinite:
|
||||
|
@ -88,7 +89,15 @@ infinite:
|
|||
p.countdown--
|
||||
if p.countdown < 0 {
|
||||
t.Stop()
|
||||
p.UpdateSession(infoUI)
|
||||
p.UpdateSession()
|
||||
drawInfo(
|
||||
infoUI,
|
||||
p.cycle,
|
||||
p.workSession,
|
||||
p.maxWorkSessions,
|
||||
p.label,
|
||||
)
|
||||
alert(p.label)
|
||||
time.Sleep(1 * time.Second)
|
||||
t = time.NewTicker(1 * time.Second)
|
||||
} else {
|
||||
|
@ -110,7 +119,7 @@ func (p *Pominal) Stop() {
|
|||
// If a 'long break' session is over then the Pominal cycle
|
||||
// is incremented and the work session counter is reset
|
||||
// to 1.
|
||||
func (p *Pominal) UpdateSession(i *tview.TextView) {
|
||||
func (p *Pominal) UpdateSession() {
|
||||
switch p.label {
|
||||
case workTimerLabel:
|
||||
if p.workSession >= p.maxWorkSessions {
|
||||
|
@ -133,8 +142,6 @@ func (p *Pominal) UpdateSession(i *tview.TextView) {
|
|||
p.countdown = p.work
|
||||
p.label = workTimerLabel
|
||||
}
|
||||
drawInfo(i, p.cycle, p.workSession, p.maxWorkSessions, p.label)
|
||||
alert(p.label)
|
||||
}
|
||||
|
||||
// setSessionTime returns the minimum session time
|
||||
|
|
Loading…
Reference in a new issue