1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

stop widget's scheduler if the widget disabled after live-reloading

This commit is contained in:
Hossein Mehrabi 2018-06-08 01:46:13 +04:30
parent 9dbf5065f2
commit af98a750f1

View File

@ -9,7 +9,7 @@ type Scheduler interface {
RefreshInterval() int
}
func Schedule(widget Scheduler) {
func Schedule(widget Wtfable) {
// Kick off the first refresh and then leave the rest to the timer
widget.Refresh()
@ -25,7 +25,12 @@ func Schedule(widget Scheduler) {
for {
select {
case <-tick.C:
widget.Refresh()
if widget.Enabled() {
widget.Refresh()
} else {
tick.Stop()
return
}
case <-quit:
tick.Stop()
return