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:
Dan Anglin 2020-01-19 23:10:03 +00:00
parent 1be999c8b6
commit 19b599e341
No known key found for this signature in database
GPG key ID: 7AC2B18EC1D09F27

View file

@ -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