From 9eabbd1691b40aff6e2737910bc7495751f88645 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Wed, 20 Jun 2018 10:38:31 -0700 Subject: [PATCH] Move GCal item check closer to point of impact --- gcal/widget.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gcal/widget.go b/gcal/widget.go index 1fce95b6..526ac5cc 100644 --- a/gcal/widget.go +++ b/gcal/widget.go @@ -49,6 +49,10 @@ func (widget *Widget) Disable() { /* -------------------- Unexported Functions -------------------- */ func (widget *Widget) display() { + if widget.events == nil || len(widget.events.Items) == 0 { + return + } + widget.mutex.Lock() defer widget.mutex.Unlock() widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(widget.events))) @@ -287,9 +291,7 @@ outer: for { select { case <-tick.C: - if widget.events != nil && len(widget.events.Items) > 0 { - widget.display() - } + widget.display() case <-widget.ch: break outer }