mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-09 17:44:59 +09:00
GO-1084: Clarify code
This commit is contained in:
parent
4b3618b416
commit
3d0c91a895
4 changed files with 7 additions and 10 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue