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

GO-1310: Remove one redundant class

This commit is contained in:
Sergey 2023-04-25 18:17:59 +02:00 committed by Mikhail Iudin
parent 0409001d9f
commit 5a83d7ac54
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
3 changed files with 10 additions and 39 deletions

View file

@ -133,9 +133,7 @@ func Bootstrap(a *app.App, components ...app.Component) {
objectStatusWatcher := status.NewSpaceObjectWatcher(spaceService, statusUpdateReceiver)
fileSyncStatusWatcher := filesyncstatus.New(fileSyncStatusRegistry, statusUpdateReceiver, fileSyncUpdateInterval)
fileStatusWatcher := status.NewFileWatcher(spaceService, fileSyncStatusWatcher)
statusService := status.New(sbtProvider, coreService, fileStatusWatcher, objectStatusWatcher, subObjectsStatusWatcher, linkedFilesStatusWatcher)
statusService := status.New(sbtProvider, spaceService, coreService, fileSyncStatusWatcher, objectStatusWatcher, subObjectsStatusWatcher, linkedFilesStatusWatcher)
fileService := files.New(fileSyncStatusWatcher, objectStore)

View file

@ -1,30 +0,0 @@
package status
import (
"github.com/anytypeio/go-anytype-middleware/core/filestorage/filesync/filesyncstatus"
"github.com/anytypeio/go-anytype-middleware/space"
)
type fileWatcher struct {
spaceService space.Service
fileStatusWatcher filesyncstatus.StatusWatcher
}
func NewFileWatcher(
spaceService space.Service,
fileStatusWatcher filesyncstatus.StatusWatcher,
) Watcher {
return &fileWatcher{
spaceService: spaceService,
fileStatusWatcher: fileStatusWatcher,
}
}
func (f *fileWatcher) Watch(id string) error {
f.fileStatusWatcher.Watch(f.spaceService.AccountId(), id)
return nil
}
func (f *fileWatcher) Unwatch(id string) {
f.fileStatusWatcher.Unwatch(f.spaceService.AccountId(), id)
}

View file

@ -7,9 +7,11 @@ import (
"github.com/anytypeio/any-sync/app"
"go.uber.org/zap"
"github.com/anytypeio/go-anytype-middleware/core/filestorage/filesync/filesyncstatus"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/core"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/core/smartblock"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/logging"
"github.com/anytypeio/go-anytype-middleware/space"
"github.com/anytypeio/go-anytype-middleware/space/typeprovider"
)
@ -37,10 +39,11 @@ type RunnableWatcher interface {
type service struct {
typeProvider typeprovider.SmartBlockTypeProvider
spaceService space.Service
coreService core.Service
fileWatcher Watcher
fileWatcher filesyncstatus.StatusWatcher
objectWatcher RunnableWatcher
subObjectsWatcher SubObjectsWatcher
linkedFilesWatcher LinkedFilesWatcher
@ -52,13 +55,15 @@ type service struct {
func New(
typeProvider typeprovider.SmartBlockTypeProvider,
spaceService space.Service,
coreService core.Service,
fileWatcher Watcher,
fileWatcher filesyncstatus.StatusWatcher,
objectWatcher RunnableWatcher,
subObjectsWatcher SubObjectsWatcher,
linkedFilesWatcher LinkedFilesWatcher,
) Service {
return &service{
spaceService: spaceService,
typeProvider: typeProvider,
coreService: coreService,
fileWatcher: fileWatcher,
@ -111,9 +116,7 @@ func (s *service) watch(id string, filesGetter func() []string) (new bool, err e
}
switch sbt {
case smartblock.SmartBlockTypeFile:
if err = s.fileWatcher.Watch(id); err != nil {
return false, err
}
s.fileWatcher.Watch(s.spaceService.AccountId(), id)
return false, nil
case smartblock.SmartBlockTypeSubObject:
s.subObjectsWatcher.Watch(id)
@ -137,7 +140,7 @@ func (s *service) unwatch(id string) {
}
switch sbt {
case smartblock.SmartBlockTypeFile:
s.fileWatcher.Unwatch(id)
s.fileWatcher.Unwatch(s.spaceService.AccountId(), id)
case smartblock.SmartBlockTypeSubObject:
s.subObjectsWatcher.Unwatch(id)
default: