1
0
Fork 0
mirror of https://github.com/Luzifer/streamdeck.git synced 2024-12-29 22:21:24 +00:00

Load display elements async, only fail current key on error

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2020-07-10 21:28:29 +02:00
parent 8e3a5d6ed1
commit 656a4710f0
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -229,12 +229,20 @@ func togglePage(page string) error {
activePageCtx, activePageCtxCancel = context.WithCancel(context.Background()) activePageCtx, activePageCtxCancel = context.WithCancel(context.Background())
sd.ClearAllKeys() sd.ClearAllKeys()
for idx, kd := range activePage.Keys { for idx := range activePage.Keys {
if kd.Display.Type != "" { if activePage.Keys[idx].Display.Type == "" {
continue
}
go func(idx int) {
var kd = activePage.Keys[idx]
if err := callDisplayElement(activePageCtx, idx, kd); err != nil { if err := callDisplayElement(activePageCtx, idx, kd); err != nil {
return errors.Wrapf(err, "Unable to execute display element on key %d", idx) log.WithFields(log.Fields{
} "key": idx,
"page": activePageName,
}).WithError(err).Error("Unable to execute display element")
} }
}(idx)
} }
return nil return nil