new scene system is kind of working. I haven't tested changing between scenes and Transition effect yet, though.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
+7
-14
@@ -3,7 +3,6 @@ package api
|
||||
import (
|
||||
"context"
|
||||
"git.aiterp.net/lucifer/new-server/app/config"
|
||||
"git.aiterp.net/lucifer/new-server/app/services/scene"
|
||||
"git.aiterp.net/lucifer/new-server/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@@ -56,14 +55,12 @@ func Devices(r gin.IRoutes) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_ = scene.GlobalManager().UpdateDevice(ctxOf(c), &devices[i], nil)
|
||||
|
||||
set[devices[i].ID] = true
|
||||
changed = append(changed, devices[i])
|
||||
}
|
||||
}
|
||||
|
||||
config.PublishChannel <- scene.GlobalManager().FilterUnassigned(changed)
|
||||
config.PublishChannel <- changed
|
||||
|
||||
go func() {
|
||||
for _, device := range changed {
|
||||
@@ -126,11 +123,9 @@ func Devices(r gin.IRoutes) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_ = scene.GlobalManager().UpdateDevice(ctxOf(c), &devices[i], nil)
|
||||
}
|
||||
|
||||
config.PublishChannel <- scene.GlobalManager().FilterUnassigned(devices)
|
||||
config.PublishChannel <- devices
|
||||
|
||||
go func() {
|
||||
for _, device := range devices {
|
||||
@@ -217,7 +212,7 @@ func Devices(r gin.IRoutes) {
|
||||
return []models.Device{}, nil
|
||||
}
|
||||
|
||||
assignedScene, err := config.SceneRepository().Find(ctxOf(c), body.SceneID)
|
||||
_, err = config.SceneRepository().Find(ctxOf(c), body.SceneID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -228,17 +223,15 @@ func Devices(r gin.IRoutes) {
|
||||
|
||||
for i := range devices {
|
||||
devices[i].SceneAssignments = []models.DeviceSceneAssignment{body}
|
||||
|
||||
err := scene.GlobalManager().UpdateDevice(ctxOf(c), &devices[i], assignedScene)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
config.PublishChannel <- devices
|
||||
|
||||
eg := errgroup.Group{}
|
||||
for i := range devices {
|
||||
device := devices[i]
|
||||
|
||||
eg.Go(func() error {
|
||||
return config.DeviceRepository().Save(ctxOf(c), &devices[i], 0)
|
||||
return config.DeviceRepository().Save(ctxOf(c), &device, 0)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user