Skip to content

Commit

Permalink
Fixed widget layout saving of new default layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Nemere committed Nov 2, 2023
1 parent a8befe0 commit f5bb0d7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions api/ws/handlers/screen-configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"context"
"errors"
"fmt"
"net/http"

"github.com/pixlise/core/v3/api/dbCollections"
"github.com/pixlise/core/v3/api/ws/wsHelpers"
"github.com/pixlise/core/v3/core/errorwithstatus"
protos "github.com/pixlise/core/v3/generated-protos"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
Expand All @@ -15,8 +17,8 @@ import (
"go.mongodb.org/mongo-driver/mongo/writeconcern"
)

func formUserScreenConfigurationId(user *protos.UserInfo, id string) string {
return user.Id + "-" + id
func formUserScreenConfigurationId(user *protos.UserInfo, scanId string) string {
return user.Id + "-" + scanId
}

func formWidgetId(widget *protos.WidgetLayoutConfiguration, screenConfigId string, layoutIndex int) string {
Expand Down Expand Up @@ -189,6 +191,15 @@ func writeScreenConfiguration(screenConfig *protos.ScreenConfiguration, hctx wsH
func checkIfScreenConfigurationExists(id string, hctx wsHelpers.HandlerContext, canEdit bool) (bool, error) {
_, _, err := wsHelpers.GetUserObjectById[protos.ScreenConfiguration](true, id, protos.ObjectType_OT_SCREEN_CONFIG, dbCollections.ScreenConfigurationName, hctx)
if err != nil {
switch e := err.(type) {
case errorwithstatus.Error:
if e.Status() == http.StatusNotFound {
// This is a not found error!
return false, nil
}
}

// Something else went wrong
return false, err
}

Expand Down

0 comments on commit f5bb0d7

Please sign in to comment.