mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Return when weather data cannot be read
This commit is contained in:
parent
6321182b7e
commit
6b4c7a7f5d
@ -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()
|
||||
|
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user