diff --git a/src/statusscreen/SL.go b/src/statusscreen/SL.go index 012e99c..37e8206 100644 --- a/src/statusscreen/SL.go +++ b/src/statusscreen/SL.go @@ -58,16 +58,7 @@ func (sl *SL) GetOutput() []string { // Check if it's time to refresh yet if sl.nextRefresh <= time.Now().Unix() { - // If it is, refresh the data - sldata, err := sl.getTimeTable() - - // If no error occured, save the latest data to the struct - if err == nil { - sl.lastResponse = sldata - sl.nextRefresh = time.Now().Unix() + sl.Config.SL.RefreshDelay - } else { - // log.Fatal(err) - } + sl.getData() } for _, v := range sl.lastResponse.ResponseData.Metros { @@ -89,6 +80,19 @@ func (sl *SL) GetOutput() []string { return strings.Split(b.String(), "\n") } +func (sl *SL) getData() { + // If it is, refresh the data + sldata, err := sl.getTimeTable() + + // If no error occured, save the latest data to the struct + if err == nil { + sl.lastResponse = sldata + sl.nextRefresh = time.Now().Unix() + sl.Config.SL.RefreshDelay + } else { + // log.Fatal(err) + } +} + func (sl *SL) getTimeTable() (SLResponse, error) { parsedResponse := SLResponse{}