fix(withings): remove parallel execution

resolves #2551
This commit is contained in:
Jan De Dobbeleer 2022-07-21 10:37:00 +02:00 committed by Jan De Dobbeleer
parent 7e35ff4fbc
commit b34f8bbbf3

View file

@ -9,7 +9,6 @@ import (
"oh-my-posh/properties" "oh-my-posh/properties"
"strconv" "strconv"
"strings" "strings"
"sync"
"time" "time"
http2 "net/http" http2 "net/http"
@ -147,24 +146,16 @@ func (w *Withings) Template() string {
} }
func (w *Withings) Enabled() bool { func (w *Withings) Enabled() bool {
wg := sync.WaitGroup{}
wg.Add(3)
functions := []func() bool{
w.getMeasures,
w.getActivities,
w.getSleep,
}
var enabled bool var enabled bool
for _, function := range functions { if w.getActivities() {
go func(f func() bool) { enabled = true
defer wg.Done() }
success := f() if w.getMeasures() {
if success { enabled = true
enabled = true }
} if w.getSleep() {
}(function) enabled = true
} }
wg.Wait()
return enabled return enabled
} }