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

Merge pull request #1700 from anytypeio/fix-setof-featrel-go-739

WithDefaultFeaturedRelations: add a case for set
This commit is contained in:
Roman Khafizianov 2023-01-16 11:40:34 +01:00 committed by GitHub
commit 0516518f35
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 11 deletions

View file

@ -13,7 +13,6 @@ import (
"github.com/anytypeio/go-anytype-middleware/pkg/lib/localstore/objectstore"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/pb/model"
"github.com/anytypeio/go-anytype-middleware/util/pbtypes"
"github.com/anytypeio/go-anytype-middleware/util/slice"
)
type Set struct {
@ -53,21 +52,12 @@ func (p *Set) Init(ctx *smartblock.InitContext) (err error) {
return err
}
var featuredRelations []string
if ctx.State != nil {
featuredRelations = pbtypes.GetStringList(ctx.State.Details(), bundle.RelationKeyFeaturedRelations.String())
}
// Add missing required featured relations
featuredRelations = slice.Union(featuredRelations, []string{bundle.RelationKeyDescription.String(), bundle.RelationKeyType.String(), bundle.RelationKeySetOf.String()})
featuredRelations = slice.Remove(featuredRelations, bundle.RelationKeyCreator.String())
templates := []template.StateTransformer{
template.WithDataviewRelationMigrationRelation(template.DataviewBlockId, bundle.TypeKeyBookmark.URL(), bundle.RelationKeyUrl, bundle.RelationKeySource),
template.WithObjectTypesAndLayout([]string{bundle.TypeKeySet.URL()}, model.ObjectType_set),
template.WithRelations([]bundle.RelationKey{bundle.RelationKeySetOf}),
template.WithDescription,
template.WithDetail(bundle.RelationKeyFeaturedRelations, pbtypes.StringList(featuredRelations)),
template.WithFeaturedRelations,
template.WithDefaultFeaturedRelations,
template.WithBlockEditRestricted(p.Id()),
}
if dvBlock := p.Pick(template.DataviewBlockId); dvBlock != nil {

View file

@ -279,6 +279,8 @@ var WithDefaultFeaturedRelations = StateTransformer(func(s *state.State) {
layout, _ := s.Layout()
if layout == model.ObjectType_basic || layout == model.ObjectType_note {
fr = []string{bundle.RelationKeyType.String()}
} else if layout == model.ObjectType_set {
fr = []string{bundle.RelationKeyDescription.String(), bundle.RelationKeyType.String(), bundle.RelationKeySetOf.String()}
}
s.SetDetail(bundle.RelationKeyFeaturedRelations.String(), pbtypes.StringList(fr))
}