diff --git a/core/block/source/service.go b/core/block/source/service.go index 30650f1ab..012ebbdfe 100644 --- a/core/block/source/service.go +++ b/core/block/source/service.go @@ -36,7 +36,7 @@ type Service interface { RemoveStaticSource(id string) GetDetailsFromIdBasedSource(id string) (*types.Struct, error) - SourceTypeBySbType(blockType smartblock.SmartBlockType) (SourceType, error) + IDsListerBySmartblockType(blockType smartblock.SmartBlockType) (IDsLister, error) app.Component } @@ -124,7 +124,7 @@ func (s *service) NewSource(id string, spaceID string, buildOptions commonspace. return newTreeSource(id, deps) } -func (s *service) SourceTypeBySbType(blockType smartblock.SmartBlockType) (SourceType, error) { +func (s *service) IDsListerBySmartblockType(blockType smartblock.SmartBlockType) (IDsLister, error) { switch blockType { case smartblock.SmartBlockTypeAnytypeProfile: return &anytypeProfile{}, nil @@ -143,11 +143,10 @@ func (s *service) SourceTypeBySbType(blockType smartblock.SmartBlockType) (Sourc return nil, err } else { return &source{ + smartblockType: blockType, coreService: s.coreService, spaceService: s.spaceService, - smartblockType: blockType, sbtProvider: s.sbtProvider, - fileService: s.fileService, }, nil } } diff --git a/core/block/source/source.go b/core/block/source/source.go index 5e302524b..cf3132618 100644 --- a/core/block/source/source.go +++ b/core/block/source/source.go @@ -61,14 +61,13 @@ type SourceIdEndodedDetails interface { DetailsFromId() (*types.Struct, error) } -// TODO Extract implementation from sources impl -type SourceType interface { +type IDsLister interface { ListIds() ([]string, error) } type SourceWithType interface { Source - SourceType + IDsLister } var ErrUnknownDataFormat = fmt.Errorf("unknown data format: you may need to upgrade anytype in order to open this page") diff --git a/core/block/source/static.go b/core/block/source/static.go index 0645dd443..81fedba11 100644 --- a/core/block/source/static.go +++ b/core/block/source/static.go @@ -54,7 +54,6 @@ func (s *static) PushChange(params PushChangeParams) (id string, err error) { } func (s *static) ListIds() (result []string, err error) { - // TODO move this code to service.ListStaticIDs s.s.mu.Lock() defer s.s.mu.Unlock() for id, src := range s.s.staticIds { diff --git a/core/indexer/indexer.go b/core/indexer/indexer.go index e9e1453a3..3581b41e5 100644 --- a/core/indexer/indexer.go +++ b/core/indexer/indexer.go @@ -682,11 +682,11 @@ func (i *indexer) getObjectInfo(ctx context.Context, id string) (info smartblock func (i *indexer) getIdsForTypes(sbt ...smartblock.SmartBlockType) ([]string, error) { var ids []string for _, t := range sbt { - st, err := i.source.SourceTypeBySbType(t) + lister, err := i.source.IDsListerBySmartblockType(t) if err != nil { return nil, err } - idsT, err := st.ListIds() + idsT, err := lister.ListIds() if err != nil { return nil, err }