mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 04:54:03 -08:00
parent
7e35ff4fbc
commit
b34f8bbbf3
|
@ -9,7 +9,6 @@ import (
|
|||
"oh-my-posh/properties"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
http2 "net/http"
|
||||
|
@ -147,24 +146,16 @@ func (w *Withings) Template() string {
|
|||
}
|
||||
|
||||
func (w *Withings) Enabled() bool {
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(3)
|
||||
functions := []func() bool{
|
||||
w.getMeasures,
|
||||
w.getActivities,
|
||||
w.getSleep,
|
||||
}
|
||||
var enabled bool
|
||||
for _, function := range functions {
|
||||
go func(f func() bool) {
|
||||
defer wg.Done()
|
||||
success := f()
|
||||
if success {
|
||||
enabled = true
|
||||
}
|
||||
}(function)
|
||||
if w.getActivities() {
|
||||
enabled = true
|
||||
}
|
||||
if w.getMeasures() {
|
||||
enabled = true
|
||||
}
|
||||
if w.getSleep() {
|
||||
enabled = true
|
||||
}
|
||||
wg.Wait()
|
||||
return enabled
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue