1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-11 02:13:41 +09:00

GO-1084: Cleanup source service

This commit is contained in:
Sergey 2023-04-25 18:17:59 +02:00 committed by Mikhail Iudin
parent 27f1d474bf
commit 4b3618b416
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
9 changed files with 0 additions and 104 deletions

View file

@ -39,10 +39,6 @@ func (v *anytypeProfile) Type() model.SmartBlockType {
return model.SmartBlockType_AnytypeProfile
}
func (v *anytypeProfile) Virtual() bool {
return true
}
func (v *anytypeProfile) getDetails() (p *types.Struct) {
return &types.Struct{Fields: map[string]*types.Value{
bundle.RelationKeyName.String(): pbtypes.String("Anytype"),

View file

@ -34,10 +34,6 @@ func (v *bundledObjectType) Type() model.SmartBlockType {
return model.SmartBlockType_BundledObjectType
}
func (v *bundledObjectType) Virtual() bool {
return true
}
func getDetailsForBundledObjectType(id string) (extraRels []*model.RelationLink, p *types.Struct, err error) {
ot, err := bundle.GetTypeByUrl(id)
if err != nil {

View file

@ -37,10 +37,6 @@ func (v *bundledRelation) Type() model.SmartBlockType {
return model.SmartBlockType_BundledRelation
}
func (v *bundledRelation) Virtual() bool {
return true
}
func (v *bundledRelation) getDetails(id string) (p *types.Struct, err error) {
if !strings.HasPrefix(id, addr.BundledRelationURLPrefix) {
return nil, fmt.Errorf("incorrect relation id: not a bundled relation id")

View file

@ -45,10 +45,6 @@ func (v *date) Type() model.SmartBlockType {
return model.SmartBlockType_Date
}
func (v *date) Virtual() bool {
return true
}
func (v *date) getDetails() (p *types.Struct) {
return &types.Struct{Fields: map[string]*types.Value{
bundle.RelationKeyName.String(): pbtypes.String(v.t.Format("Mon Jan 2 2006")),

View file

@ -47,10 +47,6 @@ func (f *files) Type() model.SmartBlockType {
return model.SmartBlockType_File
}
func (f *files) Virtual() bool {
return true
}
func (f *files) getDetailsForFileOrImage(ctx context.Context, id string) (p *types.Struct, isImage bool, err error) {
file, err := f.fileService.FileByHash(ctx, id)
if err != nil {

View file

@ -37,10 +37,6 @@ func (m *missingObject) Type() model.SmartBlockType {
return model.SmartBlockType_MissingObject
}
func (m *missingObject) Virtual() bool {
return true
}
func (m *missingObject) getDetails() (p *types.Struct) {
return &types.Struct{Fields: map[string]*types.Value{
bundle.RelationKeyIsDeleted.String(): pbtypes.Bool(true),

View file

@ -44,7 +44,6 @@ type ChangeReceiver interface {
type Source interface {
Id() string
Type() model.SmartBlockType
Virtual() bool
Heads() []string
GetFileKeysSnapshot() []*pb.ChangeFileKeys
ReadOnly() bool
@ -65,7 +64,6 @@ type SourceIdEndodedDetails interface {
// TODO Extract implementation from sources impl
type SourceType interface {
ListIds() ([]string, error)
Virtual() bool
}
type SourceWithType interface {
@ -178,10 +176,6 @@ func (s *source) Type() model.SmartBlockType {
return model.SmartBlockType(s.smartblockType)
}
func (s *source) Virtual() bool {
return false
}
func (s *source) ReadDoc(ctx context.Context, receiver ChangeReceiver, allowEmpty bool) (doc state.Doc, err error) {
return s.readDoc(ctx, receiver, allowEmpty)
}

View file

@ -34,10 +34,6 @@ func (s *static) Type() model.SmartBlockType {
return s.sbType
}
func (s *static) Virtual() bool {
return true
}
func (s *static) ReadOnly() bool {
return s.pushChange == nil
}

View file

@ -1,70 +0,0 @@
package source
import (
"context"
"github.com/google/uuid"
"github.com/anytypeio/go-anytype-middleware/core/block/editor/state"
"github.com/anytypeio/go-anytype-middleware/pb"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/localstore/addr"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/pb/model"
)
// TODO Remove Virtual source and all mentions about it
func NewVirtual(t model.SmartBlockType) (s Source) {
return &virtual{
id: addr.VirtualPrefix + t.String() + "_" + uuid.New().String(),
sbType: t,
}
}
type virtual struct {
id string
sbType model.SmartBlockType
}
func (v *virtual) ReadOnly() bool {
return false
}
func (v *virtual) Id() string {
return v.id
}
func (v *virtual) Type() model.SmartBlockType {
return v.sbType
}
func (v *virtual) Virtual() bool {
return true
}
func (v *virtual) ReadDoc(ctx context.Context, eceiver ChangeReceiver, empty bool) (doc state.Doc, err error) {
return state.NewDoc(v.id, nil), nil
}
func (v *virtual) ReadMeta(ctx context.Context, _ ChangeReceiver) (doc state.Doc, err error) {
return state.NewDoc(v.id, nil), nil
}
func (v *virtual) PushChange(params PushChangeParams) (id string, err error) {
return "", nil
}
func (v *virtual) ListIds() ([]string, error) {
// not supported
return nil, nil
}
func (v *virtual) Close() (err error) {
return
}
func (v *virtual) Heads() []string {
return nil
}
func (s *virtual) GetFileKeysSnapshot() []*pb.ChangeFileKeys {
return nil
}