diff --git a/core/block/collection/service.go b/core/block/collection/service.go index c059df31b..79489470c 100644 --- a/core/block/collection/service.go +++ b/core/block/collection/service.go @@ -199,7 +199,7 @@ func (s *Service) UnsubscribeFromCollection(collectionID string, subscriptionID func (s *Service) CreateCollection(details *types.Struct, flags []*model.InternalFlag) (coresb.SmartBlockType, *types.Struct, *state.State, error) { details = internalflag.PutToDetails(details, flags) - newState := state.NewDoc("", nil).NewState() + newState := state.NewDoc("", nil).NewState().SetDetails(details) tmpls := []template.StateTransformer{ template.WithRequiredRelations(), @@ -211,7 +211,7 @@ func (s *Service) CreateCollection(details *types.Struct, flags []*model.Interna ) template.InitTemplate(newState, tmpls...) - return coresb.SmartBlockTypePage, details, newState, nil + return coresb.SmartBlockTypePage, newState.CombinedDetails(), newState, nil } func (s *Service) ObjectToCollection(id string) error { diff --git a/pkg/lib/bundle/relation.gen.go b/pkg/lib/bundle/relation.gen.go index af4ec14a2..93fa17f5a 100644 --- a/pkg/lib/bundle/relation.gen.go +++ b/pkg/lib/bundle/relation.gen.go @@ -5,11 +5,11 @@ source: pkg/lib/bundle/relations.json package bundle import ( - "github.com/anytypeio/go-anytype-middleware/pkg/lib/localstore/addr" + addr "github.com/anytypeio/go-anytype-middleware/pkg/lib/localstore/addr" "github.com/anytypeio/go-anytype-middleware/pkg/lib/pb/model" ) -const RelationChecksum = "076e0450f34681ba0ea3f21585c3cf3cd83c2915210d39b6a10da94d13f54db7" +const RelationChecksum = "4a90e6d43e04243d30f1cb5b912349ebf11ae7bcaf8d2524b6a7de33d2822105" type RelationKey string @@ -160,6 +160,7 @@ const ( RelationKeySpaceDashboardId RelationKey = "spaceDashboardId" RelationKeyIconOption RelationKey = "iconOption" RelationKeySpaceAccessibility RelationKey = "spaceAccessibility" + RelationKeySourceFilePath RelationKey = "sourceFilePath" ) var ( @@ -900,7 +901,7 @@ var ( }, RelationKeyInternalFlags: { - DataSource: model.Relation_derived, + DataSource: model.Relation_details, Description: "Set of internal flags", Format: model.RelationFormat_number, Hidden: true, @@ -1237,6 +1238,7 @@ var ( DataSource: model.Relation_details, Description: "", Format: model.RelationFormat_longtext, + Hidden: true, Id: "_broldAnytypeID", Key: "oldAnytypeID", MaxCount: 1, @@ -1671,6 +1673,20 @@ var ( ReadOnlyRelation: true, Scope: model.Relation_type, }, + RelationKeySourceFilePath: { + + DataSource: model.Relation_details, + Description: "File path or url with original object", + Format: model.RelationFormat_longtext, + Hidden: true, + Id: "_brsourceFilePath", + Key: "sourceFilePath", + MaxCount: 1, + Name: "Source file path", + ReadOnly: false, + ReadOnlyRelation: true, + Scope: model.Relation_type, + }, RelationKeySourceObject: { DataSource: model.Relation_details, diff --git a/pkg/lib/bundle/relations.json b/pkg/lib/bundle/relations.json index 3d2aefa04..7cb38a3c0 100644 --- a/pkg/lib/bundle/relations.json +++ b/pkg/lib/bundle/relations.json @@ -984,7 +984,7 @@ "maxCount": 0, "name": "Internal flags", "readonly": true, - "source": "derived" + "source": "details" }, { "format": "url", diff --git a/util/internalflag/flag.go b/util/internalflag/flag.go index b24ace6ef..6d0e5e971 100644 --- a/util/internalflag/flag.go +++ b/util/internalflag/flag.go @@ -1,11 +1,12 @@ package internalflag import ( + "github.com/gogo/protobuf/types" + "github.com/anytypeio/go-anytype-middleware/core/block/editor/state" "github.com/anytypeio/go-anytype-middleware/pkg/lib/bundle" "github.com/anytypeio/go-anytype-middleware/pkg/lib/pb/model" "github.com/anytypeio/go-anytype-middleware/util/pbtypes" - "github.com/gogo/protobuf/types" ) const relationKey = bundle.RelationKeyInternalFlags @@ -15,7 +16,7 @@ type Set struct { } func NewFromState(st *state.State) Set { - flags := pbtypes.GetIntList(st.LocalDetails(), relationKey.String()) + flags := pbtypes.GetIntList(st.CombinedDetails(), relationKey.String()) return Set{ flags: flags, @@ -50,7 +51,7 @@ func (s *Set) Remove(flag model.InternalFlagValue) { func (s Set) AddToState(st *state.State) { if len(s.flags) == 0 { - st.RemoveLocalDetail(relationKey.String()) + st.RemoveDetail(relationKey.String()) return } st.SetDetailAndBundledRelation(relationKey, pbtypes.IntList(s.flags...))