diff --git a/bamboohr/widget.go b/bamboohr/widget.go index 0e9ffed9..7093276a 100644 --- a/bamboohr/widget.go +++ b/bamboohr/widget.go @@ -16,14 +16,14 @@ type Widget struct { func NewWidget() *Widget { widget := Widget{ BaseWidget: wtf.BaseWidget{ - Name: "BambooHR", - RefreshedAt: time.Now(), - RefreshInterval: 15, + Name: "BambooHR", + RefreshedAt: time.Now(), + RefreshInt: 15, }, } widget.addView() - go widget.refresher() + go wtf.Refresh(&widget) return &widget } @@ -82,18 +82,3 @@ func (widget *Widget) display(item Item) string { return str } - -func (widget *Widget) refresher() { - tick := time.NewTicker(time.Duration(widget.RefreshInterval) * time.Minute) - quit := make(chan struct{}) - - for { - select { - case <-tick.C: - widget.Refresh() - case <-quit: - tick.Stop() - return - } - } -} diff --git a/gcal/widget.go b/gcal/widget.go index 3c4c3c79..9830bca9 100644 --- a/gcal/widget.go +++ b/gcal/widget.go @@ -18,14 +18,14 @@ type Widget struct { func NewWidget() *Widget { widget := Widget{ BaseWidget: wtf.BaseWidget{ - Name: "Calendar", - RefreshedAt: time.Now(), - RefreshInterval: 3, + Name: "Calendar", + RefreshedAt: time.Now(), + RefreshInt: 180, }, } widget.addView() - go widget.refresher() + go wtf.Refresh(&widget) return &widget } @@ -95,21 +95,6 @@ func descriptionColor(item *calendar.Event) string { return color } -func (widget *Widget) refresher() { - tick := time.NewTicker(time.Duration(widget.RefreshInterval) * time.Minute) - quit := make(chan struct{}) - - for { - select { - case <-tick.C: - widget.Refresh() - case <-quit: - tick.Stop() - return - } - } -} - // until returns the number of hours or days until the event // If the event is in the past, returns nil func (widget *Widget) until(start time.Time) string { diff --git a/git/widget.go b/git/widget.go index b1ece2d4..1c2db598 100644 --- a/git/widget.go +++ b/git/widget.go @@ -18,14 +18,14 @@ type Widget struct { func NewWidget() *Widget { widget := Widget{ BaseWidget: wtf.BaseWidget{ - Name: "Git", - RefreshedAt: time.Now(), - RefreshInterval: 10, + Name: "Git", + RefreshedAt: time.Now(), + RefreshInt: 10, }, } widget.addView() - go widget.refresher() + go wtf.Refresh(&widget) return &widget } @@ -116,18 +116,3 @@ func (widget *Widget) formatCommits(data []string) string { func (widget *Widget) formatCommit(line string) string { return fmt.Sprintf(" %s\n", strings.Replace(line, "\"", "", -1)) } - -func (widget *Widget) refresher() { - tick := time.NewTicker(time.Duration(widget.RefreshInterval) * time.Minute) - quit := make(chan struct{}) - - for { - select { - case <-tick.C: - widget.Refresh() - case <-quit: - tick.Stop() - return - } - } -} diff --git a/jira/widget.go b/jira/widget.go index 25b706b1..c230e28a 100644 --- a/jira/widget.go +++ b/jira/widget.go @@ -16,14 +16,14 @@ type Widget struct { func NewWidget() *Widget { widget := Widget{ BaseWidget: wtf.BaseWidget{ - Name: "JIRA", - RefreshedAt: time.Now(), - RefreshInterval: 8, + Name: "JIRA", + RefreshedAt: time.Now(), + RefreshInt: 900, }, } widget.addView() - go widget.refresher() + go wtf.Refresh(&widget) return &widget } @@ -49,18 +49,3 @@ func (widget *Widget) addView() { widget.View = view } - -func (widget *Widget) refresher() { - tick := time.NewTicker(time.Duration(widget.RefreshInterval) * time.Hour) - quit := make(chan struct{}) - - for { - select { - case <-tick.C: - widget.Refresh() - case <-quit: - tick.Stop() - return - } - } -} diff --git a/opsgenie/widget.go b/opsgenie/widget.go index 85e73cb6..e6b889f5 100644 --- a/opsgenie/widget.go +++ b/opsgenie/widget.go @@ -16,14 +16,14 @@ type Widget struct { func NewWidget() *Widget { widget := Widget{ BaseWidget: wtf.BaseWidget{ - Name: "OpsGenie", - RefreshedAt: time.Now(), - RefreshInterval: 8, + Name: "OpsGenie", + RefreshedAt: time.Now(), + RefreshInt: 28800, }, } widget.addView() - go widget.refresher() + go wtf.Refresh(&widget) return &widget } @@ -49,18 +49,3 @@ func (widget *Widget) addView() { widget.View = view } - -func (widget *Widget) refresher() { - tick := time.NewTicker(time.Duration(widget.RefreshInterval) * time.Hour) - quit := make(chan struct{}) - - for { - select { - case <-tick.C: - widget.Refresh() - case <-quit: - tick.Stop() - return - } - } -} diff --git a/security/widget.go b/security/widget.go index bcf4a839..b7db046a 100644 --- a/security/widget.go +++ b/security/widget.go @@ -17,14 +17,14 @@ type Widget struct { func NewWidget() *Widget { widget := Widget{ BaseWidget: wtf.BaseWidget{ - Name: "Security", - RefreshedAt: time.Now(), - RefreshInterval: 60, + Name: "Security", + RefreshedAt: time.Now(), + RefreshInt: 3600, }, } widget.addView() - go widget.refresher() + go wtf.Refresh(&widget) return &widget } @@ -70,18 +70,3 @@ func (widget *Widget) contentFrom(data map[string]string) string { return str } - -func (widget *Widget) refresher() { - tick := time.NewTicker(time.Duration(widget.RefreshInterval) * time.Minute) - quit := make(chan struct{}) - - for { - select { - case <-tick.C: - widget.Refresh() - case <-quit: - tick.Stop() - return - } - } -} diff --git a/status/widget.go b/status/widget.go index 057ea46c..9fe9697e 100644 --- a/status/widget.go +++ b/status/widget.go @@ -17,14 +17,14 @@ type Widget struct { func NewWidget() *Widget { widget := Widget{ BaseWidget: wtf.BaseWidget{ - Name: "Status", - RefreshedAt: time.Now(), - RefreshInterval: 1, + Name: "Status", + RefreshedAt: time.Now(), + RefreshInt: 1, }, } widget.addView() - go widget.refresher() + go wtf.Refresh(&widget) return &widget } @@ -54,18 +54,3 @@ func (widget *Widget) addView() { func (widget *Widget) contentFrom() string { return fmt.Sprint(rand.Intn(100)) } - -func (widget *Widget) refresher() { - tick := time.NewTicker(time.Duration(widget.RefreshInterval) * time.Second) - quit := make(chan struct{}) - - for { - select { - case <-tick.C: - widget.Refresh() - case <-quit: - tick.Stop() - return - } - } -} diff --git a/weather/widget.go b/weather/widget.go index 00c70f44..56a24cc7 100644 --- a/weather/widget.go +++ b/weather/widget.go @@ -18,14 +18,14 @@ type Widget struct { func NewWidget() *Widget { widget := Widget{ BaseWidget: wtf.BaseWidget{ - Name: "Weather", - RefreshedAt: time.Now(), - RefreshInterval: 15, + Name: "Weather", + RefreshedAt: time.Now(), + RefreshInt: 900, }, } widget.addView() - go widget.refresher() + go wtf.Refresh(&widget) return &widget } @@ -132,21 +132,6 @@ func icon(data *owm.CurrentWeatherData) string { return icon } -func (widget *Widget) refresher() { - tick := time.NewTicker(time.Duration(widget.RefreshInterval) * time.Minute) - quit := make(chan struct{}) - - for { - select { - case <-tick.C: - widget.Refresh() - case <-quit: - tick.Stop() - return - } - } -} - func (widget *Widget) refreshedAt() string { return widget.RefreshedAt.Format("15:04:05") }