mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-09 17:44:59 +09:00
make internalFlags a normal relation
This commit is contained in:
parent
19f6124d22
commit
881cf07cf1
4 changed files with 26 additions and 9 deletions
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -984,7 +984,7 @@
|
|||
"maxCount": 0,
|
||||
"name": "Internal flags",
|
||||
"readonly": true,
|
||||
"source": "derived"
|
||||
"source": "details"
|
||||
},
|
||||
{
|
||||
"format": "url",
|
||||
|
|
|
@ -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...))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue