From 93695dc4be0c134ef22cc9cdac9e0f402721aa41 Mon Sep 17 00:00:00 2001 From: appflowy Date: Thu, 24 Feb 2022 20:36:24 +0800 Subject: [PATCH] chore: rename structs --- .../infrastructure/repos/document_repo.dart | 6 +- .../infrastructure/repos/view_repo.dart | 6 +- .../dart_event/flowy-folder/dart_event.dart | 16 +- .../flowy-folder-data-model/view.pb.dart | 41 ---- .../flowy-folder-data-model/view.pbjson.dart | 10 - .../flowy-folder/event_map.pbenum.dart | 4 +- .../flowy-folder/event_map.pbjson.dart | 4 +- frontend/rust-lib/dart-ffi/Cargo.toml | 4 +- .../rust-lib/flowy-document/src/manager.rs | 6 +- .../rust-lib/flowy-folder/src/event_map.rs | 14 +- .../src/protobuf/model/event_map.rs | 20 +- .../src/protobuf/proto/event_map.proto | 2 +- .../src/services/view/event_handler.rs | 23 ++- .../flowy-folder/tests/workspace/helper.rs | 17 +- .../flowy-folder/tests/workspace/script.rs | 2 +- .../flowy-collaboration/src/synchronizer.rs | 2 +- .../src/entities/view.rs | 49 +---- .../src/protobuf/model/view.rs | 185 ++---------------- .../src/protobuf/proto/view.proto | 3 - 19 files changed, 83 insertions(+), 331 deletions(-) diff --git a/frontend/app_flowy/lib/workspace/infrastructure/repos/document_repo.dart b/frontend/app_flowy/lib/workspace/infrastructure/repos/document_repo.dart index 1bf613af29..80c122919d 100644 --- a/frontend/app_flowy/lib/workspace/infrastructure/repos/document_repo.dart +++ b/frontend/app_flowy/lib/workspace/infrastructure/repos/document_repo.dart @@ -11,8 +11,8 @@ class DocumentRepository { }); Future> openDocument() { - final request = QueryViewRequest(viewIds: [docId]); - return FolderEventOpenDocument(request).send(); + final request = ViewId(viewId: docId); + return FolderEventOpenView(request).send(); } Future> composeDelta({required String data}) { @@ -23,7 +23,7 @@ class DocumentRepository { } Future> closeDocument() { - final request = QueryViewRequest(viewIds: [docId]); + final request = ViewId(viewId: docId); return FolderEventCloseView(request).send(); } } diff --git a/frontend/app_flowy/lib/workspace/infrastructure/repos/view_repo.dart b/frontend/app_flowy/lib/workspace/infrastructure/repos/view_repo.dart index 3ee6fcaef4..4b3918b734 100644 --- a/frontend/app_flowy/lib/workspace/infrastructure/repos/view_repo.dart +++ b/frontend/app_flowy/lib/workspace/infrastructure/repos/view_repo.dart @@ -18,7 +18,7 @@ class ViewRepository { }); Future> readView() { - final request = QueryViewRequest(viewIds: [view.id]); + final request = ViewId(viewId: view.id); return FolderEventReadView(request).send(); } @@ -37,12 +37,12 @@ class ViewRepository { } Future> delete() { - final request = QueryViewRequest.create()..viewIds.add(view.id); + final request = RepeatedViewId.create()..items.add(view.id); return FolderEventDeleteView(request).send(); } Future> duplicate() { - final request = QueryViewRequest.create()..viewIds.add(view.id); + final request = ViewId(viewId: view.id); return FolderEventDuplicateView(request).send(); } } diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-folder/dart_event.dart b/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-folder/dart_event.dart index 21f7f3c598..190fb5831d 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-folder/dart_event.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-folder/dart_event.dart @@ -186,7 +186,7 @@ class FolderEventCreateView { } class FolderEventReadView { - QueryViewRequest request; + ViewId request; FolderEventReadView(this.request); Future> send() { @@ -220,7 +220,7 @@ class FolderEventUpdateView { } class FolderEventDeleteView { - QueryViewRequest request; + RepeatedViewId request; FolderEventDeleteView(this.request); Future> send() { @@ -237,7 +237,7 @@ class FolderEventDeleteView { } class FolderEventDuplicateView { - QueryViewRequest request; + ViewId request; FolderEventDuplicateView(this.request); Future> send() { @@ -267,13 +267,13 @@ class FolderEventCopyLink { } } -class FolderEventOpenDocument { - QueryViewRequest request; - FolderEventOpenDocument(this.request); +class FolderEventOpenView { + ViewId request; + FolderEventOpenView(this.request); Future> send() { final request = FFIRequest.create() - ..event = FolderEvent.OpenDocument.toString() + ..event = FolderEvent.OpenView.toString() ..payload = requestToBytes(this.request); return Dispatch.asyncRequest(request) @@ -285,7 +285,7 @@ class FolderEventOpenDocument { } class FolderEventCloseView { - QueryViewRequest request; + ViewId request; FolderEventCloseView(this.request); Future> send() { diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder-data-model/view.pb.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder-data-model/view.pb.dart index 6719facbbe..96f8518031 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder-data-model/view.pb.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder-data-model/view.pb.dart @@ -463,47 +463,6 @@ class CreateViewParams extends $pb.GeneratedMessage { void clearViewId() => clearField(7); } -class QueryViewRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'QueryViewRequest', createEmptyInstance: create) - ..pPS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'viewIds') - ..hasRequiredFields = false - ; - - QueryViewRequest._() : super(); - factory QueryViewRequest({ - $core.Iterable<$core.String>? viewIds, - }) { - final _result = create(); - if (viewIds != null) { - _result.viewIds.addAll(viewIds); - } - return _result; - } - factory QueryViewRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory QueryViewRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - QueryViewRequest clone() => QueryViewRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - QueryViewRequest copyWith(void Function(QueryViewRequest) updates) => super.copyWith((message) => updates(message as QueryViewRequest)) as QueryViewRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static QueryViewRequest create() => QueryViewRequest._(); - QueryViewRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static QueryViewRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static QueryViewRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.List<$core.String> get viewIds => $_getList(0); -} - class ViewId extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ViewId', createEmptyInstance: create) ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'viewId') diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder-data-model/view.pbjson.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder-data-model/view.pbjson.dart index 91c8dd6fa5..437e515483 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder-data-model/view.pbjson.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder-data-model/view.pbjson.dart @@ -80,16 +80,6 @@ const CreateViewParams$json = const { /// Descriptor for `CreateViewParams`. Decode as a `google.protobuf.DescriptorProto`. final $typed_data.Uint8List createViewParamsDescriptor = $convert.base64Decode('ChBDcmVhdGVWaWV3UGFyYW1zEiAKDGJlbG9uZ190b19pZBgBIAEoCVIKYmVsb25nVG9JZBISCgRuYW1lGAIgASgJUgRuYW1lEhIKBGRlc2MYAyABKAlSBGRlc2MSHAoJdGh1bWJuYWlsGAQgASgJUgl0aHVtYm5haWwSJgoJdmlld190eXBlGAUgASgOMgkuVmlld1R5cGVSCHZpZXdUeXBlEhsKCXZpZXdfZGF0YRgGIAEoCVIIdmlld0RhdGESFwoHdmlld19pZBgHIAEoCVIGdmlld0lk'); -@$core.Deprecated('Use queryViewRequestDescriptor instead') -const QueryViewRequest$json = const { - '1': 'QueryViewRequest', - '2': const [ - const {'1': 'view_ids', '3': 1, '4': 3, '5': 9, '10': 'viewIds'}, - ], -}; - -/// Descriptor for `QueryViewRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List queryViewRequestDescriptor = $convert.base64Decode('ChBRdWVyeVZpZXdSZXF1ZXN0EhkKCHZpZXdfaWRzGAEgAygJUgd2aWV3SWRz'); @$core.Deprecated('Use viewIdDescriptor instead') const ViewId$json = const { '1': 'ViewId', diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder/event_map.pbenum.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder/event_map.pbenum.dart index 8af53a2c96..dd502e087f 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder/event_map.pbenum.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder/event_map.pbenum.dart @@ -26,7 +26,7 @@ class FolderEvent extends $pb.ProtobufEnum { static const FolderEvent DeleteView = FolderEvent._(204, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DeleteView'); static const FolderEvent DuplicateView = FolderEvent._(205, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DuplicateView'); static const FolderEvent CopyLink = FolderEvent._(206, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CopyLink'); - static const FolderEvent OpenDocument = FolderEvent._(207, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'OpenDocument'); + static const FolderEvent OpenView = FolderEvent._(207, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'OpenView'); static const FolderEvent CloseView = FolderEvent._(208, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CloseView'); static const FolderEvent ReadTrash = FolderEvent._(300, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ReadTrash'); static const FolderEvent PutbackTrash = FolderEvent._(301, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'PutbackTrash'); @@ -53,7 +53,7 @@ class FolderEvent extends $pb.ProtobufEnum { DeleteView, DuplicateView, CopyLink, - OpenDocument, + OpenView, CloseView, ReadTrash, PutbackTrash, diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder/event_map.pbjson.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder/event_map.pbjson.dart index 2fb5760954..e992c85ab7 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder/event_map.pbjson.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder/event_map.pbjson.dart @@ -28,7 +28,7 @@ const FolderEvent$json = const { const {'1': 'DeleteView', '2': 204}, const {'1': 'DuplicateView', '2': 205}, const {'1': 'CopyLink', '2': 206}, - const {'1': 'OpenDocument', '2': 207}, + const {'1': 'OpenView', '2': 207}, const {'1': 'CloseView', '2': 208}, const {'1': 'ReadTrash', '2': 300}, const {'1': 'PutbackTrash', '2': 301}, @@ -41,4 +41,4 @@ const FolderEvent$json = const { }; /// Descriptor for `FolderEvent`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List folderEventDescriptor = $convert.base64Decode('CgtGb2xkZXJFdmVudBITCg9DcmVhdGVXb3Jrc3BhY2UQABIUChBSZWFkQ3VyV29ya3NwYWNlEAESEgoOUmVhZFdvcmtzcGFjZXMQAhITCg9EZWxldGVXb3Jrc3BhY2UQAxIRCg1PcGVuV29ya3NwYWNlEAQSFQoRUmVhZFdvcmtzcGFjZUFwcHMQBRINCglDcmVhdGVBcHAQZRINCglEZWxldGVBcHAQZhILCgdSZWFkQXBwEGcSDQoJVXBkYXRlQXBwEGgSDwoKQ3JlYXRlVmlldxDJARINCghSZWFkVmlldxDKARIPCgpVcGRhdGVWaWV3EMsBEg8KCkRlbGV0ZVZpZXcQzAESEgoNRHVwbGljYXRlVmlldxDNARINCghDb3B5TGluaxDOARIRCgxPcGVuRG9jdW1lbnQQzwESDgoJQ2xvc2VWaWV3ENABEg4KCVJlYWRUcmFzaBCsAhIRCgxQdXRiYWNrVHJhc2gQrQISEAoLRGVsZXRlVHJhc2gQrgISFAoPUmVzdG9yZUFsbFRyYXNoEK8CEhMKDkRlbGV0ZUFsbFRyYXNoELACEhIKDUFwcGx5RG9jRGVsdGEQkAMSEwoORXhwb3J0RG9jdW1lbnQQ9AM='); +final $typed_data.Uint8List folderEventDescriptor = $convert.base64Decode('CgtGb2xkZXJFdmVudBITCg9DcmVhdGVXb3Jrc3BhY2UQABIUChBSZWFkQ3VyV29ya3NwYWNlEAESEgoOUmVhZFdvcmtzcGFjZXMQAhITCg9EZWxldGVXb3Jrc3BhY2UQAxIRCg1PcGVuV29ya3NwYWNlEAQSFQoRUmVhZFdvcmtzcGFjZUFwcHMQBRINCglDcmVhdGVBcHAQZRINCglEZWxldGVBcHAQZhILCgdSZWFkQXBwEGcSDQoJVXBkYXRlQXBwEGgSDwoKQ3JlYXRlVmlldxDJARINCghSZWFkVmlldxDKARIPCgpVcGRhdGVWaWV3EMsBEg8KCkRlbGV0ZVZpZXcQzAESEgoNRHVwbGljYXRlVmlldxDNARINCghDb3B5TGluaxDOARINCghPcGVuVmlldxDPARIOCglDbG9zZVZpZXcQ0AESDgoJUmVhZFRyYXNoEKwCEhEKDFB1dGJhY2tUcmFzaBCtAhIQCgtEZWxldGVUcmFzaBCuAhIUCg9SZXN0b3JlQWxsVHJhc2gQrwISEwoORGVsZXRlQWxsVHJhc2gQsAISEgoNQXBwbHlEb2NEZWx0YRCQAxITCg5FeHBvcnREb2N1bWVudBD0Aw=='); diff --git a/frontend/rust-lib/dart-ffi/Cargo.toml b/frontend/rust-lib/dart-ffi/Cargo.toml index 96755db623..046fd85668 100644 --- a/frontend/rust-lib/dart-ffi/Cargo.toml +++ b/frontend/rust-lib/dart-ffi/Cargo.toml @@ -7,8 +7,8 @@ edition = "2018" [lib] name = "dart_ffi" # this value will change depending on the target os -# default staticlib -crate-type = ["staticlib"] +# default cdylib +crate-type = ["cdylib"] [dependencies] diff --git a/frontend/rust-lib/flowy-document/src/manager.rs b/frontend/rust-lib/flowy-document/src/manager.rs index 5beaa11d4e..d02fa876e0 100644 --- a/frontend/rust-lib/flowy-document/src/manager.rs +++ b/frontend/rust-lib/flowy-document/src/manager.rs @@ -164,10 +164,8 @@ struct DocumentRevisionCloudServiceImpl { impl RevisionCloudService for DocumentRevisionCloudServiceImpl { #[tracing::instrument(level = "trace", skip(self))] - fn fetch_object(&self, user_id: &str, doc_id: &str) -> FutureResult, FlowyError> { - let params = DocumentId { - doc_id: doc_id.to_string(), - }; + fn fetch_object(&self, user_id: &str, object_id: &str) -> FutureResult, FlowyError> { + let params: DocumentId = object_id.to_string().into(); let server = self.server.clone(); let token = self.token.clone(); let user_id = user_id.to_string(); diff --git a/frontend/rust-lib/flowy-folder/src/event_map.rs b/frontend/rust-lib/flowy-folder/src/event_map.rs index 3df6e55218..56aca5b3ff 100644 --- a/frontend/rust-lib/flowy-folder/src/event_map.rs +++ b/frontend/rust-lib/flowy-folder/src/event_map.rs @@ -63,7 +63,7 @@ pub fn create(folder: Arc) -> Module { .event(FolderEvent::UpdateView, update_view_handler) .event(FolderEvent::DeleteView, delete_view_handler) .event(FolderEvent::DuplicateView, duplicate_view_handler) - .event(FolderEvent::OpenDocument, open_document_handler) + .event(FolderEvent::OpenView, open_document_handler) .event(FolderEvent::CloseView, close_view_handler) .event(FolderEvent::ApplyDocDelta, document_delta_handler); @@ -115,25 +115,25 @@ pub enum FolderEvent { #[event(input = "CreateViewRequest", output = "View")] CreateView = 201, - #[event(input = "QueryViewRequest", output = "View")] + #[event(input = "ViewId", output = "View")] ReadView = 202, #[event(input = "UpdateViewRequest", output = "View")] UpdateView = 203, - #[event(input = "QueryViewRequest")] + #[event(input = "RepeatedViewId")] DeleteView = 204, - #[event(input = "QueryViewRequest")] + #[event(input = "ViewId")] DuplicateView = 205, #[event()] CopyLink = 206, - #[event(input = "QueryViewRequest", output = "DocumentDelta")] - OpenDocument = 207, + #[event(input = "ViewId", output = "DocumentDelta")] + OpenView = 207, - #[event(input = "QueryViewRequest")] + #[event(input = "ViewId")] CloseView = 208, #[event(output = "RepeatedTrash")] diff --git a/frontend/rust-lib/flowy-folder/src/protobuf/model/event_map.rs b/frontend/rust-lib/flowy-folder/src/protobuf/model/event_map.rs index 556a71f14d..58606cda0d 100644 --- a/frontend/rust-lib/flowy-folder/src/protobuf/model/event_map.rs +++ b/frontend/rust-lib/flowy-folder/src/protobuf/model/event_map.rs @@ -41,7 +41,7 @@ pub enum FolderEvent { DeleteView = 204, DuplicateView = 205, CopyLink = 206, - OpenDocument = 207, + OpenView = 207, CloseView = 208, ReadTrash = 300, PutbackTrash = 301, @@ -75,7 +75,7 @@ impl ::protobuf::ProtobufEnum for FolderEvent { 204 => ::std::option::Option::Some(FolderEvent::DeleteView), 205 => ::std::option::Option::Some(FolderEvent::DuplicateView), 206 => ::std::option::Option::Some(FolderEvent::CopyLink), - 207 => ::std::option::Option::Some(FolderEvent::OpenDocument), + 207 => ::std::option::Option::Some(FolderEvent::OpenView), 208 => ::std::option::Option::Some(FolderEvent::CloseView), 300 => ::std::option::Option::Some(FolderEvent::ReadTrash), 301 => ::std::option::Option::Some(FolderEvent::PutbackTrash), @@ -106,7 +106,7 @@ impl ::protobuf::ProtobufEnum for FolderEvent { FolderEvent::DeleteView, FolderEvent::DuplicateView, FolderEvent::CopyLink, - FolderEvent::OpenDocument, + FolderEvent::OpenView, FolderEvent::CloseView, FolderEvent::ReadTrash, FolderEvent::PutbackTrash, @@ -143,19 +143,19 @@ impl ::protobuf::reflect::ProtobufValue for FolderEvent { } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x0fevent_map.proto*\xd6\x03\n\x0bFolderEvent\x12\x13\n\x0fCreateWorks\ + \n\x0fevent_map.proto*\xd2\x03\n\x0bFolderEvent\x12\x13\n\x0fCreateWorks\ pace\x10\0\x12\x14\n\x10ReadCurWorkspace\x10\x01\x12\x12\n\x0eReadWorksp\ aces\x10\x02\x12\x13\n\x0fDeleteWorkspace\x10\x03\x12\x11\n\rOpenWorkspa\ ce\x10\x04\x12\x15\n\x11ReadWorkspaceApps\x10\x05\x12\r\n\tCreateApp\x10\ e\x12\r\n\tDeleteApp\x10f\x12\x0b\n\x07ReadApp\x10g\x12\r\n\tUpdateApp\ \x10h\x12\x0f\n\nCreateView\x10\xc9\x01\x12\r\n\x08ReadView\x10\xca\x01\ \x12\x0f\n\nUpdateView\x10\xcb\x01\x12\x0f\n\nDeleteView\x10\xcc\x01\x12\ - \x12\n\rDuplicateView\x10\xcd\x01\x12\r\n\x08CopyLink\x10\xce\x01\x12\ - \x11\n\x0cOpenDocument\x10\xcf\x01\x12\x0e\n\tCloseView\x10\xd0\x01\x12\ - \x0e\n\tReadTrash\x10\xac\x02\x12\x11\n\x0cPutbackTrash\x10\xad\x02\x12\ - \x10\n\x0bDeleteTrash\x10\xae\x02\x12\x14\n\x0fRestoreAllTrash\x10\xaf\ - \x02\x12\x13\n\x0eDeleteAllTrash\x10\xb0\x02\x12\x12\n\rApplyDocDelta\ - \x10\x90\x03\x12\x13\n\x0eExportDocument\x10\xf4\x03b\x06proto3\ + \x12\n\rDuplicateView\x10\xcd\x01\x12\r\n\x08CopyLink\x10\xce\x01\x12\r\ + \n\x08OpenView\x10\xcf\x01\x12\x0e\n\tCloseView\x10\xd0\x01\x12\x0e\n\tR\ + eadTrash\x10\xac\x02\x12\x11\n\x0cPutbackTrash\x10\xad\x02\x12\x10\n\x0b\ + DeleteTrash\x10\xae\x02\x12\x14\n\x0fRestoreAllTrash\x10\xaf\x02\x12\x13\ + \n\x0eDeleteAllTrash\x10\xb0\x02\x12\x12\n\rApplyDocDelta\x10\x90\x03\ + \x12\x13\n\x0eExportDocument\x10\xf4\x03b\x06proto3\ "; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; diff --git a/frontend/rust-lib/flowy-folder/src/protobuf/proto/event_map.proto b/frontend/rust-lib/flowy-folder/src/protobuf/proto/event_map.proto index 56d4fecd2d..a21f0f92c7 100644 --- a/frontend/rust-lib/flowy-folder/src/protobuf/proto/event_map.proto +++ b/frontend/rust-lib/flowy-folder/src/protobuf/proto/event_map.proto @@ -17,7 +17,7 @@ enum FolderEvent { DeleteView = 204; DuplicateView = 205; CopyLink = 206; - OpenDocument = 207; + OpenView = 207; CloseView = 208; ReadTrash = 300; PutbackTrash = 301; diff --git a/frontend/rust-lib/flowy-folder/src/services/view/event_handler.rs b/frontend/rust-lib/flowy-folder/src/services/view/event_handler.rs index 71b9634abd..1fde366196 100644 --- a/frontend/rust-lib/flowy-folder/src/services/view/event_handler.rs +++ b/frontend/rust-lib/flowy-folder/src/services/view/event_handler.rs @@ -2,8 +2,7 @@ use crate::{ entities::{ trash::Trash, view::{ - CreateViewParams, CreateViewRequest, QueryViewRequest, RepeatedViewId, UpdateViewParams, UpdateViewRequest, - View, ViewId, + CreateViewParams, CreateViewRequest, RepeatedViewId, UpdateViewParams, UpdateViewRequest, View, ViewId, }, }, errors::FlowyError, @@ -24,10 +23,10 @@ pub(crate) async fn create_view_handler( } pub(crate) async fn read_view_handler( - data: Data, + data: Data, controller: Unit>, ) -> DataResult { - let params: ViewId = data.into_inner().try_into()?; + let params: ViewId = data.into_inner(); let mut view = controller.read_view(params.clone()).await?; // For the moment, app and view can contains lots of views. Reading the view // belongings using the view_id. @@ -56,11 +55,11 @@ pub(crate) async fn document_delta_handler( } pub(crate) async fn delete_view_handler( - data: Data, + data: Data, view_controller: Unit>, trash_controller: Unit>, ) -> Result<(), FlowyError> { - let params: RepeatedViewId = data.into_inner().try_into()?; + let params: RepeatedViewId = data.into_inner(); for view_id in ¶ms.items { let _ = view_controller.delete_view(view_id.into()).await; } @@ -77,29 +76,29 @@ pub(crate) async fn delete_view_handler( } pub(crate) async fn open_document_handler( - data: Data, + data: Data, controller: Unit>, ) -> DataResult { - let params: ViewId = data.into_inner().try_into()?; + let params: ViewId = data.into_inner(); let doc = controller.open_document(¶ms.view_id).await?; data_result(doc) } pub(crate) async fn close_view_handler( - data: Data, + data: Data, controller: Unit>, ) -> Result<(), FlowyError> { - let params: ViewId = data.into_inner().try_into()?; + let params: ViewId = data.into_inner(); let _ = controller.close_view(¶ms.view_id).await?; Ok(()) } #[tracing::instrument(skip(data, controller), err)] pub(crate) async fn duplicate_view_handler( - data: Data, + data: Data, controller: Unit>, ) -> Result<(), FlowyError> { - let params: ViewId = data.into_inner().try_into()?; + let params: ViewId = data.into_inner(); let _ = controller.duplicate_view(¶ms.view_id).await?; Ok(()) } diff --git a/frontend/rust-lib/flowy-folder/tests/workspace/helper.rs b/frontend/rust-lib/flowy-folder/tests/workspace/helper.rs index f67c9961bd..551987c9c9 100644 --- a/frontend/rust-lib/flowy-folder/tests/workspace/helper.rs +++ b/frontend/rust-lib/flowy-folder/tests/workspace/helper.rs @@ -1,9 +1,10 @@ use flowy_collaboration::entities::document_info::DocumentInfo; use flowy_folder::event_map::FolderEvent::*; +use flowy_folder_data_model::entities::view::{RepeatedViewId, ViewId}; use flowy_folder_data_model::entities::{ app::{App, AppId, CreateAppRequest, QueryAppRequest, UpdateAppRequest}, trash::{RepeatedTrash, TrashId, TrashType}, - view::{CreateViewRequest, QueryViewRequest, UpdateViewRequest, View, ViewType}, + view::{CreateViewRequest, UpdateViewRequest, View, ViewType}, workspace::{CreateWorkspaceRequest, QueryWorkspaceRequest, RepeatedWorkspace, Workspace}, }; use flowy_test::{event_builder::*, FlowySDKTest}; @@ -124,8 +125,10 @@ pub async fn create_view(sdk: &FlowySDKTest, app_id: &str, name: &str, desc: &st view } -pub async fn read_view(sdk: &FlowySDKTest, view_ids: Vec) -> View { - let request = QueryViewRequest { view_ids }; +pub async fn read_view(sdk: &FlowySDKTest, view_id: &str) -> View { + let request = ViewId { + view_id: view_id.to_string(), + }; FolderEventBuilder::new(sdk.clone()) .event(ReadView) .request(request) @@ -149,7 +152,7 @@ pub async fn update_view(sdk: &FlowySDKTest, view_id: &str, name: Option } pub async fn delete_view(sdk: &FlowySDKTest, view_ids: Vec) { - let request = QueryViewRequest { view_ids }; + let request = RepeatedViewId { items: view_ids }; FolderEventBuilder::new(sdk.clone()) .event(DeleteView) .request(request) @@ -158,11 +161,11 @@ pub async fn delete_view(sdk: &FlowySDKTest, view_ids: Vec) { } pub async fn open_document(sdk: &FlowySDKTest, view_id: &str) -> DocumentInfo { - let request = QueryViewRequest { - view_ids: vec![view_id.to_owned()], + let request = ViewId { + view_id: view_id.to_string(), }; FolderEventBuilder::new(sdk.clone()) - .event(OpenDocument) + .event(OpenView) .request(request) .async_send() .await diff --git a/frontend/rust-lib/flowy-folder/tests/workspace/script.rs b/frontend/rust-lib/flowy-folder/tests/workspace/script.rs index d9a0addd13..df2d6259d5 100644 --- a/frontend/rust-lib/flowy-folder/tests/workspace/script.rs +++ b/frontend/rust-lib/flowy-folder/tests/workspace/script.rs @@ -153,7 +153,7 @@ impl FolderTest { assert_eq!(self.view, view); } FolderScript::ReadView(view_id) => { - let view = read_view(sdk, vec![view_id]).await; + let view = read_view(sdk, &view_id).await; self.view = view; } FolderScript::UpdateView { name, desc } => { diff --git a/shared-lib/flowy-collaboration/src/synchronizer.rs b/shared-lib/flowy-collaboration/src/synchronizer.rs index 78e11ed565..2f9603fec8 100644 --- a/shared-lib/flowy-collaboration/src/synchronizer.rs +++ b/shared-lib/flowy-collaboration/src/synchronizer.rs @@ -149,7 +149,7 @@ where match server_rev_id.cmp(&client_rev_id) { Ordering::Less => { - tracing::error!("Client should not send ping and the server should pull the revisions from the client") + tracing::warn!("Client should not send ping and the server should pull the revisions from the client") } Ordering::Equal => tracing::trace!("{} is up to date.", object_id), Ordering::Greater => { diff --git a/shared-lib/flowy-folder-data-model/src/entities/view.rs b/shared-lib/flowy-folder-data-model/src/entities/view.rs index b7141a8a79..27473b9f42 100644 --- a/shared-lib/flowy-folder-data-model/src/entities/view.rs +++ b/shared-lib/flowy-folder-data-model/src/entities/view.rs @@ -177,39 +177,19 @@ impl TryInto for CreateViewRequest { } } -#[derive(Default, ProtoBuf)] -pub struct QueryViewRequest { - #[pb(index = 1)] - pub view_ids: Vec, -} - #[derive(Default, ProtoBuf, Clone, Debug)] pub struct ViewId { #[pb(index = 1)] pub view_id: String, } -impl std::convert::From for ViewId { - fn from(view_id: String) -> Self { - ViewId { view_id } - } -} - -impl TryInto for QueryViewRequest { - type Error = ErrorCode; - fn try_into(self) -> Result { - debug_assert!(self.view_ids.len() == 1); - if self.view_ids.len() != 1 { - log::error!("The len of view_ids should be equal to 1"); - return Err(ErrorCode::ViewIdInvalid); - } - - let view_id = self.view_ids.first().unwrap().clone(); - let view_id = ViewIdentify::parse(view_id)?.0; - - Ok(ViewId { view_id }) - } -} +// impl std::convert::From for ViewId { +// fn from(value: T) -> Self { +// ViewId { +// view_id: value.to_string(), +// } +// } +// } #[derive(Default, ProtoBuf)] pub struct RepeatedViewId { @@ -217,21 +197,6 @@ pub struct RepeatedViewId { pub items: Vec, } -impl TryInto for QueryViewRequest { - type Error = ErrorCode; - - fn try_into(self) -> Result { - let mut view_ids = vec![]; - for view_id in self.view_ids { - let view_id = ViewIdentify::parse(view_id)?.0; - - view_ids.push(view_id); - } - - Ok(RepeatedViewId { items: view_ids }) - } -} - #[derive(Default, ProtoBuf)] pub struct UpdateViewRequest { #[pb(index = 1)] diff --git a/shared-lib/flowy-folder-data-model/src/protobuf/model/view.rs b/shared-lib/flowy-folder-data-model/src/protobuf/model/view.rs index 0d306b1b80..83da30425d 100644 --- a/shared-lib/flowy-folder-data-model/src/protobuf/model/view.rs +++ b/shared-lib/flowy-folder-data-model/src/protobuf/model/view.rs @@ -1423,164 +1423,6 @@ impl ::protobuf::reflect::ProtobufValue for CreateViewParams { } } -#[derive(PartialEq,Clone,Default)] -pub struct QueryViewRequest { - // message fields - pub view_ids: ::protobuf::RepeatedField<::std::string::String>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a QueryViewRequest { - fn default() -> &'a QueryViewRequest { - ::default_instance() - } -} - -impl QueryViewRequest { - pub fn new() -> QueryViewRequest { - ::std::default::Default::default() - } - - // repeated string view_ids = 1; - - - pub fn get_view_ids(&self) -> &[::std::string::String] { - &self.view_ids - } - pub fn clear_view_ids(&mut self) { - self.view_ids.clear(); - } - - // Param is passed by value, moved - pub fn set_view_ids(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { - self.view_ids = v; - } - - // Mutable pointer to the field. - pub fn mut_view_ids(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { - &mut self.view_ids - } - - // Take field - pub fn take_view_ids(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { - ::std::mem::replace(&mut self.view_ids, ::protobuf::RepeatedField::new()) - } -} - -impl ::protobuf::Message for QueryViewRequest { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.view_ids)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - for value in &self.view_ids { - my_size += ::protobuf::rt::string_size(1, &value); - }; - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - for v in &self.view_ids { - os.write_string(1, &v)?; - }; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &dyn (::std::any::Any) { - self as &dyn (::std::any::Any) - } - fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { - self as &mut dyn (::std::any::Any) - } - fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> QueryViewRequest { - QueryViewRequest::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "view_ids", - |m: &QueryViewRequest| { &m.view_ids }, - |m: &mut QueryViewRequest| { &mut m.view_ids }, - )); - ::protobuf::reflect::MessageDescriptor::new_pb_name::( - "QueryViewRequest", - fields, - file_descriptor_proto() - ) - }) - } - - fn default_instance() -> &'static QueryViewRequest { - static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; - instance.get(QueryViewRequest::new) - } -} - -impl ::protobuf::Clear for QueryViewRequest { - fn clear(&mut self) { - self.view_ids.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for QueryViewRequest { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for QueryViewRequest { - fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { - ::protobuf::reflect::ReflectValueRef::Message(self) - } -} - #[derive(PartialEq,Clone,Default)] pub struct ViewId { // message fields @@ -2773,20 +2615,19 @@ static file_descriptor_proto_data: &'static [u8] = b"\ me\x12\x12\n\x04desc\x18\x03\x20\x01(\tR\x04desc\x12\x1c\n\tthumbnail\ \x18\x04\x20\x01(\tR\tthumbnail\x12&\n\tview_type\x18\x05\x20\x01(\x0e2\ \t.ViewTypeR\x08viewType\x12\x1b\n\tview_data\x18\x06\x20\x01(\tR\x08vie\ - wData\x12\x17\n\x07view_id\x18\x07\x20\x01(\tR\x06viewId\"-\n\x10QueryVi\ - ewRequest\x12\x19\n\x08view_ids\x18\x01\x20\x03(\tR\x07viewIds\"!\n\x06V\ - iewId\x12\x17\n\x07view_id\x18\x01\x20\x01(\tR\x06viewId\"&\n\x0eRepeate\ - dViewId\x12\x14\n\x05items\x18\x01\x20\x03(\tR\x05items\"\xaa\x01\n\x11U\ - pdateViewRequest\x12\x17\n\x07view_id\x18\x01\x20\x01(\tR\x06viewId\x12\ - \x14\n\x04name\x18\x02\x20\x01(\tH\0R\x04name\x12\x14\n\x04desc\x18\x03\ - \x20\x01(\tH\x01R\x04desc\x12\x1e\n\tthumbnail\x18\x04\x20\x01(\tH\x02R\ - \tthumbnailB\r\n\x0bone_of_nameB\r\n\x0bone_of_descB\x12\n\x10one_of_thu\ - mbnail\"\xa9\x01\n\x10UpdateViewParams\x12\x17\n\x07view_id\x18\x01\x20\ - \x01(\tR\x06viewId\x12\x14\n\x04name\x18\x02\x20\x01(\tH\0R\x04name\x12\ - \x14\n\x04desc\x18\x03\x20\x01(\tH\x01R\x04desc\x12\x1e\n\tthumbnail\x18\ - \x04\x20\x01(\tH\x02R\tthumbnailB\r\n\x0bone_of_nameB\r\n\x0bone_of_desc\ - B\x12\n\x10one_of_thumbnail*\x1e\n\x08ViewType\x12\t\n\x05Blank\x10\0\ - \x12\x07\n\x03Doc\x10\x01b\x06proto3\ + wData\x12\x17\n\x07view_id\x18\x07\x20\x01(\tR\x06viewId\"!\n\x06ViewId\ + \x12\x17\n\x07view_id\x18\x01\x20\x01(\tR\x06viewId\"&\n\x0eRepeatedView\ + Id\x12\x14\n\x05items\x18\x01\x20\x03(\tR\x05items\"\xaa\x01\n\x11Update\ + ViewRequest\x12\x17\n\x07view_id\x18\x01\x20\x01(\tR\x06viewId\x12\x14\n\ + \x04name\x18\x02\x20\x01(\tH\0R\x04name\x12\x14\n\x04desc\x18\x03\x20\ + \x01(\tH\x01R\x04desc\x12\x1e\n\tthumbnail\x18\x04\x20\x01(\tH\x02R\tthu\ + mbnailB\r\n\x0bone_of_nameB\r\n\x0bone_of_descB\x12\n\x10one_of_thumbnai\ + l\"\xa9\x01\n\x10UpdateViewParams\x12\x17\n\x07view_id\x18\x01\x20\x01(\ + \tR\x06viewId\x12\x14\n\x04name\x18\x02\x20\x01(\tH\0R\x04name\x12\x14\n\ + \x04desc\x18\x03\x20\x01(\tH\x01R\x04desc\x12\x1e\n\tthumbnail\x18\x04\ + \x20\x01(\tH\x02R\tthumbnailB\r\n\x0bone_of_nameB\r\n\x0bone_of_descB\ + \x12\n\x10one_of_thumbnail*\x1e\n\x08ViewType\x12\t\n\x05Blank\x10\0\x12\ + \x07\n\x03Doc\x10\x01b\x06proto3\ "; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; diff --git a/shared-lib/flowy-folder-data-model/src/protobuf/proto/view.proto b/shared-lib/flowy-folder-data-model/src/protobuf/proto/view.proto index ba4aa0d7f3..43ece49eda 100644 --- a/shared-lib/flowy-folder-data-model/src/protobuf/proto/view.proto +++ b/shared-lib/flowy-folder-data-model/src/protobuf/proto/view.proto @@ -30,9 +30,6 @@ message CreateViewParams { string view_data = 6; string view_id = 7; } -message QueryViewRequest { - repeated string view_ids = 1; -} message ViewId { string view_id = 1; }