diff --git a/wavesrv/pkg/scbus/modelupdate.go b/wavesrv/pkg/scbus/modelupdate.go index 4e6f36056..0917f1aaf 100644 --- a/wavesrv/pkg/scbus/modelupdate.go +++ b/wavesrv/pkg/scbus/modelupdate.go @@ -72,16 +72,16 @@ func (*ModelUpdatePacketType) GetType() string { return ModelUpdateStr } -func (mu *ModelUpdatePacketType) IsEmpty() bool { - if mu == nil || mu.Data == nil { +func (upk *ModelUpdatePacketType) IsEmpty() bool { + if upk == nil { return true } - return mu.Data.IsEmpty() + return upk.Data.IsEmpty() } // Clean the ClientData in an update, if present func (upk *ModelUpdatePacketType) Clean() { - if upk == nil || upk.Data == nil { + if upk.IsEmpty() { return } for _, item := range *(upk.Data) { @@ -106,6 +106,9 @@ func MakeUpdatePacket() *ModelUpdatePacketType { // Returns the items in the update that are of type I func GetUpdateItems[I ModelUpdateItem](upk *ModelUpdatePacketType) []*I { + if upk.IsEmpty() { + return nil + } ret := make([]*I, 0) for _, item := range *(upk.Data) { if i, ok := (item).(I); ok { diff --git a/wavesrv/pkg/scbus/scbus.go b/wavesrv/pkg/scbus/scbus.go index 7ce8d2545..f9cefe298 100644 --- a/wavesrv/pkg/scbus/scbus.go +++ b/wavesrv/pkg/scbus/scbus.go @@ -110,7 +110,7 @@ func MakeUpdateBus() *UpdateBus { // Send an update to all channels in the collection func (bus *UpdateBus) DoUpdate(update UpdatePacket) { - if update == nil || update.IsEmpty() { + if update.IsEmpty() { return } update.Clean() @@ -128,7 +128,7 @@ func (bus *UpdateBus) DoUpdate(update UpdatePacket) { // Send a model update to only clients that are subscribed to the given screenId func (bus *UpdateBus) DoScreenUpdate(screenId string, update UpdatePacket) { - if update == nil { + if update.IsEmpty() { return } update.Clean()