From 19b599e341ab71c0277a1973f0c17c2fa651d206 Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Sun, 19 Jan 2020 23:10:03 +0000 Subject: [PATCH] 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. --- pominal.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pominal.go b/pominal.go index ccc011e..e3ba5b5 100644 --- a/pominal.go +++ b/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