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:
parent
27f1d474bf
commit
4b3618b416
9 changed files with 0 additions and 104 deletions
|
@ -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"),
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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")),
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue