From 6b4c7a7f5dd23e8ca4428e03edafa8d7f1273241 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Mon, 16 Apr 2018 06:26:04 -0700 Subject: [PATCH] Return when weather data cannot be read --- status/widget.go | 1 + weather/widget.go | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/status/widget.go b/status/widget.go index 29d689bd..06822b87 100644 --- a/status/widget.go +++ b/status/widget.go @@ -34,6 +34,7 @@ func (widget *Widget) Refresh() { return } + // FIXME: Use two calls to wtf.RightAlign here and get rid of this code duplication _, _, w, _ := widget.View.GetInnerRect() widget.View.Clear() diff --git a/weather/widget.go b/weather/widget.go index 0f6785c5..24572f18 100644 --- a/weather/widget.go +++ b/weather/widget.go @@ -37,17 +37,18 @@ func (widget *Widget) Refresh() { data := Fetch(wtf.ToInts(Config.UList("wtf.mods.weather.cityids", widget.defaultCityCodes()))) widget.View.Clear() - widget.contentFrom(data) + widget.contentFor(data) widget.RefreshedAt = time.Now() } /* -------------------- Unexported Functions -------------------- */ -func (widget *Widget) contentFrom(data []*owm.CurrentWeatherData) { +func (widget *Widget) contentFor(data []*owm.CurrentWeatherData) { cityData := widget.currentCityData(data) if len(cityData.Weather) == 0 { fmt.Fprintf(widget.View, "%s", " Weather data is unavailable.") + return } widget.View.SetTitle(widget.contentTitle(cityData))