1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 09:35:00 +09:00

Merge branch 'master' of ssh://github.com/anytypeio/go-anytype-middleware into updated-getstarted

# Conflicts:
#	util/pbtypes/pbtypes.go
This commit is contained in:
Roman Khafizianov 2023-01-17 15:38:57 +01:00
commit 2a60a48a82
No known key found for this signature in database
GPG key ID: F07A7D55A2684852
14 changed files with 121 additions and 60 deletions

View file

@ -58,7 +58,7 @@ type BuiltinObjects interface {
}
type objectCreator interface {
CreateSmartBlockFromState(ctx context.Context, sbType coresb.SmartBlockType, details *types.Struct, relationIds []string, createState *state.State) (id string, newDetails *types.Struct, err error)
CreateSmartBlockFromState(ctx context.Context, sbType coresb.SmartBlockType, details *types.Struct, createState *state.State) (id string, newDetails *types.Struct, err error)
}
type builtinObjects struct {
@ -257,7 +257,7 @@ func (b *builtinObjects) createObject(ctx context.Context, rd io.ReadCloser) (er
return err
}
_, _, err = b.objectCreator.CreateSmartBlockFromState(ctx, sbt, nil, nil, st)
_, _, err = b.objectCreator.CreateSmartBlockFromState(ctx, sbt, nil, st)
if isFavorite {
err = b.service.SetPageIsFavorite(pb.RpcObjectSetIsFavoriteRequest{ContextId: newId, IsFavorite: true})
if err != nil {

View file

@ -428,3 +428,15 @@ func StructCompareIgnoreKeys(st1 *types.Struct, st2 *types.Struct, ignoreKeys []
}
return true
}
// ValueListWrapper wraps single value into the list. If value is already a list, it is returned as is.
// Null and struct values are not supported
func ValueListWrapper(value *types.Value) (*types.ListValue, error) {
switch v := value.Kind.(type) {
case *types.Value_ListValue:
return v.ListValue, nil
case *types.Value_StringValue, *types.Value_NumberValue, *types.Value_BoolValue:
return &types.ListValue{Values: []*types.Value{value}}, nil
}
return nil, fmt.Errorf("not supported type")
}