Find Active or Most Recent Timer
This commit is contained in:
parent
2378c9e617
commit
3165c0254d
@ -165,6 +165,13 @@ func (p *Program) GetFilteredTimerList(args []string) *timertxt.TimerList {
|
||||
return list.Filter(doFilters)
|
||||
}
|
||||
|
||||
func (p *Program) GetActiveOrMostRecent() (*timertxt.Timer, error) {
|
||||
work, wErr := p.TimerList.GetActiveOrMostRecent()
|
||||
if wErr == nil {
|
||||
return work, nil
|
||||
}
|
||||
return p.GetMostRecentTimer()
|
||||
}
|
||||
func (p *Program) GetMostRecentTimer() (*timertxt.Timer, error) {
|
||||
work, wErr := p.TimerList.GetMostRecentTimer()
|
||||
if wErr == nil && work.FinishDate.IsZero() {
|
||||
|
@ -46,7 +46,7 @@ func opI3Status(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
state := "Idle"
|
||||
wrk, err := p.GetMostRecentTimer()
|
||||
wrk, err := p.GetActiveOrMostRecent()
|
||||
if err != nil {
|
||||
fmt.Print("{\"icon\":\"time\",\"state\":\"Critical\", \"text\": \"Error loading timer entry\"}")
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user