From 6a02520f8405272890833e14e1b780c39e418ded Mon Sep 17 00:00:00 2001 From: appflowy Date: Thu, 29 Jul 2021 22:22:35 +0800 Subject: [PATCH] refactor app and view can carry belongings --- .../lib/startup/tasks/application_task.dart | 3 +- app_flowy/lib/workspace/domain/i_app.dart | 7 +- .../lib/workspace/domain/i_workspace.dart | 8 +- .../workspace/infrastructure/i_app_impl.dart | 5 +- .../workspace/infrastructure/i_view_impl.dart | 2 +- .../infrastructure/i_workspace_impl.dart | 5 +- .../infrastructure/repos/app_repo.dart | 46 +++--- .../infrastructure/repos/view_repo.dart | 12 +- .../infrastructure/repos/workspace_repo.dart | 43 ++++-- .../presentation/app/app_header.dart | 5 +- .../flowy-workspace/app_create.pb.dart | 18 +-- .../flowy-workspace/app_create.pbjson.dart | 4 +- .../flowy-workspace/app_query.pb.dart | 16 +-- .../flowy-workspace/app_query.pbjson.dart | 4 +- .../flowy-workspace/observable.pbenum.dart | 28 ++-- .../flowy-workspace/observable.pbjson.dart | 16 ++- .../flowy-workspace/view_create.pb.dart | 16 +++ .../flowy-workspace/view_create.pbjson.dart | 3 +- .../flowy-workspace/view_query.pb.dart | 14 ++ .../flowy-workspace/view_query.pbjson.dart | 3 +- .../src/entities/app/app_create.rs | 2 +- .../src/entities/app/app_query.rs | 10 +- .../src/entities/view/view_create.rs | 3 + .../src/entities/view/view_query.rs | 6 + .../src/handlers/app_handler.rs | 4 +- .../src/handlers/view_handler.rs | 8 +- .../src/observable/observable.rs | 15 +- .../src/protobuf/model/app_create.rs | 136 +++++++++--------- .../src/protobuf/model/app_query.rs | 60 ++++---- .../src/protobuf/model/observable.rs | 90 +++++++----- .../src/protobuf/model/view_create.rs | 91 ++++++++++-- .../src/protobuf/model/view_query.rs | 55 +++++-- .../src/protobuf/proto/app_create.proto | 2 +- .../src/protobuf/proto/app_query.proto | 2 +- .../src/protobuf/proto/observable.proto | 14 +- .../src/protobuf/proto/view_create.proto | 1 + .../src/protobuf/proto/view_query.proto | 1 + .../src/services/app_controller.rs | 8 +- .../src/services/view_controller.rs | 7 +- .../src/services/workspace_controller.rs | 14 +- .../src/sql_tables/app/app_sql.rs | 8 +- .../src/sql_tables/app/app_table.rs | 2 +- .../src/sql_tables/view/view_sql.rs | 10 +- .../src/sql_tables/view/view_table.rs | 3 +- .../flowy-workspace/tests/event/app_test.rs | 4 +- 45 files changed, 531 insertions(+), 283 deletions(-) diff --git a/app_flowy/lib/startup/tasks/application_task.dart b/app_flowy/lib/startup/tasks/application_task.dart index 416310e470..e880602a9b 100644 --- a/app_flowy/lib/startup/tasks/application_task.dart +++ b/app_flowy/lib/startup/tasks/application_task.dart @@ -1,5 +1,6 @@ import 'package:app_flowy/startup/startup.dart'; import 'package:flowy_infra/theme.dart'; +import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:window_size/window_size.dart'; @@ -34,7 +35,7 @@ class ApplicationWidget extends StatelessWidget { return Provider.value( value: theme, child: MaterialApp( - title: 'AppFlowy', + builder: overlayManagerBuilder(), debugShowCheckedModeBanner: false, theme: theme.themeData, navigatorKey: AppGlobals.rootNavKey, diff --git a/app_flowy/lib/workspace/domain/i_app.dart b/app_flowy/lib/workspace/domain/i_app.dart index 3114cd3f0b..1aac74ec37 100644 --- a/app_flowy/lib/workspace/domain/i_app.dart +++ b/app_flowy/lib/workspace/domain/i_app.dart @@ -2,7 +2,10 @@ import 'package:flowy_sdk/protobuf/flowy-workspace/protobuf.dart'; import 'package:dartz/dartz.dart'; typedef AppUpdatedCallback = void Function(String name, String desc); -typedef AppAddViewCallback = void Function( +typedef AppCreateViewCallback = void Function( + Either, WorkspaceError> viewsOrFailed); + +typedef AppDeleteViewCallback = void Function( Either, WorkspaceError> viewsOrFailed); abstract class IApp { @@ -14,7 +17,7 @@ abstract class IApp { abstract class IAppWatch { void startWatching( - {AppAddViewCallback? addViewCallback, + {AppCreateViewCallback? addViewCallback, AppUpdatedCallback? updatedCallback}); Future stopWatching(); diff --git a/app_flowy/lib/workspace/domain/i_workspace.dart b/app_flowy/lib/workspace/domain/i_workspace.dart index 5656ee5b98..1b7d30ac8e 100644 --- a/app_flowy/lib/workspace/domain/i_workspace.dart +++ b/app_flowy/lib/workspace/domain/i_workspace.dart @@ -1,10 +1,14 @@ import 'package:flowy_sdk/protobuf/flowy-workspace/protobuf.dart'; import 'package:dartz/dartz.dart'; -typedef WorkspaceAddAppCallback = void Function( +typedef WorkspaceCreateAppCallback = void Function( Either, WorkspaceError> appsOrFail); + typedef WorkspaceUpdatedCallback = void Function(String name, String desc); +typedef WorkspaceDeleteAppCallback = void Function( + Either, WorkspaceError> appsOrFail); + abstract class IWorkspace { Future> createApp( {required String name, String? desc}); @@ -14,7 +18,7 @@ abstract class IWorkspace { abstract class IWorkspaceWatch { void startWatching( - {WorkspaceAddAppCallback? addAppCallback, + {WorkspaceCreateAppCallback? addAppCallback, WorkspaceUpdatedCallback? updatedCallback}); Future stopWatching(); diff --git a/app_flowy/lib/workspace/infrastructure/i_app_impl.dart b/app_flowy/lib/workspace/infrastructure/i_app_impl.dart index 9f5cb7ed7c..8c33e6cd2e 100644 --- a/app_flowy/lib/workspace/infrastructure/i_app_impl.dart +++ b/app_flowy/lib/workspace/infrastructure/i_app_impl.dart @@ -51,10 +51,9 @@ class IAppWatchImpl extends IAppWatch { @override void startWatching( - {AppAddViewCallback? addViewCallback, + {AppCreateViewCallback? addViewCallback, AppUpdatedCallback? updatedCallback}) { - repo.startWatching( - addViewCallback: addViewCallback, updatedCallback: updatedCallback); + repo.startWatching(createView: addViewCallback, update: updatedCallback); } @override diff --git a/app_flowy/lib/workspace/infrastructure/i_view_impl.dart b/app_flowy/lib/workspace/infrastructure/i_view_impl.dart index a4aff46ba3..1c41899e3f 100644 --- a/app_flowy/lib/workspace/infrastructure/i_view_impl.dart +++ b/app_flowy/lib/workspace/infrastructure/i_view_impl.dart @@ -23,7 +23,7 @@ class IViewWatchImpl extends IViewWatch { @override void startWatching({ViewUpdatedCallback? updatedCallback}) { - repo.startWatching(updatedCallback: updatedCallback); + repo.startWatching(update: updatedCallback); } @override diff --git a/app_flowy/lib/workspace/infrastructure/i_workspace_impl.dart b/app_flowy/lib/workspace/infrastructure/i_workspace_impl.dart index 748ae3538d..08dd8392cf 100644 --- a/app_flowy/lib/workspace/infrastructure/i_workspace_impl.dart +++ b/app_flowy/lib/workspace/infrastructure/i_workspace_impl.dart @@ -37,10 +37,9 @@ class IWorkspaceWatchImpl extends IWorkspaceWatch { @override void startWatching( - {WorkspaceAddAppCallback? addAppCallback, + {WorkspaceCreateAppCallback? addAppCallback, WorkspaceUpdatedCallback? updatedCallback}) { - repo.startWatching( - addAppCallback: addAppCallback, updatedCallback: updatedCallback); + repo.startWatching(createApp: addAppCallback, update: updatedCallback); } @override diff --git a/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart b/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart index acd9c2b4b3..b0c4dbbbaf 100644 --- a/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart +++ b/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart @@ -21,7 +21,7 @@ class AppRepository { Future> getAppDesc() { final request = QueryAppRequest.create() ..appId = appId - ..readViews = false; + ..readBelongings = false; return WorkspaceEventReadApp(request).send(); } @@ -40,11 +40,11 @@ class AppRepository { Future, WorkspaceError>> getViews() { final request = QueryAppRequest.create() ..appId = appId - ..readViews = true; + ..readBelongings = true; return WorkspaceEventReadApp(request).send().then((result) { return result.fold( - (app) => left(app.views.items), + (app) => left(app.belongings.items), (error) => right(error), ); }); @@ -53,8 +53,9 @@ class AppRepository { class AppWatchRepository { StreamSubscription? _subscription; - AppAddViewCallback? _addViewCallback; - AppUpdatedCallback? _updatedCallback; + AppCreateViewCallback? _createView; + AppDeleteViewCallback? _deleteView; + AppUpdatedCallback? _update; String appId; late AppRepository _repo; AppWatchRepository({ @@ -64,10 +65,12 @@ class AppWatchRepository { } void startWatching( - {AppAddViewCallback? addViewCallback, - AppUpdatedCallback? updatedCallback}) { - _addViewCallback = addViewCallback; - _updatedCallback = updatedCallback; + {AppCreateViewCallback? createView, + AppDeleteViewCallback? deleteView, + AppUpdatedCallback? update}) { + _createView = createView; + _deleteView = deleteView; + _update = update; _subscription = RustStreamReceiver.listen((observable) { if (observable.subjectId != appId) { return; @@ -82,24 +85,35 @@ class AppWatchRepository { void _handleObservableType(WorkspaceObservable ty) { switch (ty) { - case WorkspaceObservable.AppAddView: - if (_addViewCallback == null) { + case WorkspaceObservable.AppCreateView: + if (_createView == null) { return; } _repo.getViews().then((result) { result.fold( - (views) => _addViewCallback!(left(views)), - (error) => _addViewCallback!(right(error)), + (views) => _createView!(left(views)), + (error) => _createView!(right(error)), ); }); break; - case WorkspaceObservable.AppUpdateDesc: - if (_updatedCallback == null) { + case WorkspaceObservable.AppDeleteView: + if (_deleteView == null) { + return; + } + _repo.getViews().then((result) { + result.fold( + (views) => _deleteView!(left(views)), + (error) => _deleteView!(right(error)), + ); + }); + break; + case WorkspaceObservable.AppUpdated: + if (_update == null) { return; } _repo.getAppDesc().then((result) { result.fold( - (app) => _updatedCallback!(app.name, app.desc), + (app) => _update!(app.name, app.desc), (error) => Log.error(error), ); }); diff --git a/app_flowy/lib/workspace/infrastructure/repos/view_repo.dart b/app_flowy/lib/workspace/infrastructure/repos/view_repo.dart index dbed197f50..0b5b846757 100644 --- a/app_flowy/lib/workspace/infrastructure/repos/view_repo.dart +++ b/app_flowy/lib/workspace/infrastructure/repos/view_repo.dart @@ -26,7 +26,7 @@ class ViewRepository { class ViewWatchRepository { StreamSubscription? _subscription; - ViewUpdatedCallback? _updatedCallback; + ViewUpdatedCallback? _update; View view; late ViewRepository _repo; ViewWatchRepository({ @@ -36,9 +36,9 @@ class ViewWatchRepository { } void startWatching({ - ViewUpdatedCallback? updatedCallback, + ViewUpdatedCallback? update, }) { - _updatedCallback = updatedCallback; + _update = update; _subscription = RustStreamReceiver.listen((observable) { if (observable.subjectId != view.id) { return; @@ -53,13 +53,13 @@ class ViewWatchRepository { void _handleObservableType(WorkspaceObservable ty) { switch (ty) { - case WorkspaceObservable.ViewUpdateDesc: - if (_updatedCallback == null) { + case WorkspaceObservable.ViewUpdated: + if (_update == null) { return; } _repo.readView().then((result) { result.fold( - (view) => _updatedCallback!(view), + (view) => _update!(view), (error) => Log.error(error), ); }); diff --git a/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart b/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart index 1181eebf04..b5d1a03bdf 100644 --- a/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart +++ b/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart @@ -53,8 +53,9 @@ class WorkspaceRepo { class WorkspaceWatchRepo { StreamSubscription? _subscription; - WorkspaceAddAppCallback? _addAppCallback; - WorkspaceUpdatedCallback? _updatedCallback; + WorkspaceCreateAppCallback? _createApp; + WorkspaceDeleteAppCallback? _deleteApp; + WorkspaceUpdatedCallback? _update; final UserDetail user; late WorkspaceRepo _repo; @@ -64,11 +65,14 @@ class WorkspaceWatchRepo { _repo = WorkspaceRepo(user: user); } - void startWatching( - {WorkspaceAddAppCallback? addAppCallback, - WorkspaceUpdatedCallback? updatedCallback}) { - _addAppCallback = addAppCallback; - _updatedCallback = updatedCallback; + void startWatching({ + WorkspaceCreateAppCallback? createApp, + WorkspaceDeleteAppCallback? deleteApp, + WorkspaceUpdatedCallback? update, + }) { + _createApp = createApp; + _deleteApp = deleteApp; + _update = update; _subscription = RustStreamReceiver.listen((observable) { if (observable.subjectId != user.workspace) { @@ -84,25 +88,36 @@ class WorkspaceWatchRepo { void _handleObservableType(WorkspaceObservable ty) { switch (ty) { - case WorkspaceObservable.WorkspaceUpdateDesc: - if (_updatedCallback == null) { + case WorkspaceObservable.WorkspaceUpdated: + if (_update == null) { return; } _repo.getWorkspace().then((result) { result.fold( - (workspace) => _updatedCallback!(workspace.name, workspace.desc), + (workspace) => _update!(workspace.name, workspace.desc), (error) => Log.error(error), ); }); break; - case WorkspaceObservable.WorkspaceAddApp: - if (_addAppCallback == null) { + case WorkspaceObservable.WorkspaceCreateApp: + if (_createApp == null) { return; } _repo.getWorkspace(readApps: true).then((result) { result.fold( - (workspace) => _addAppCallback!(left(workspace.apps.items)), - (error) => _addAppCallback!(right(error)), + (workspace) => _createApp!(left(workspace.apps.items)), + (error) => _createApp!(right(error)), + ); + }); + break; + case WorkspaceObservable.WorkspaceDeleteApp: + if (_deleteApp == null) { + return; + } + _repo.getWorkspace(readApps: true).then((result) { + result.fold( + (workspace) => _deleteApp!(left(workspace.apps.items)), + (error) => _deleteApp!(right(error)), ); }); break; diff --git a/app_flowy/lib/workspace/presentation/app/app_header.dart b/app_flowy/lib/workspace/presentation/app/app_header.dart index d58c50ce4f..f55729dfa8 100644 --- a/app_flowy/lib/workspace/presentation/app/app_header.dart +++ b/app_flowy/lib/workspace/presentation/app/app_header.dart @@ -1,5 +1,6 @@ import 'package:app_flowy/workspace/application/app/app_bloc.dart'; import 'package:expandable/expandable.dart'; +import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_infra_ui/style_widget/icon_button.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flowy_infra_ui/style_widget/text_button.dart'; @@ -45,7 +46,7 @@ class AppHeader extends StatelessWidget { child: FlowyTextButton( app.name, onPressed: () { - debugPrint('show app document'); + debugPrint('show app'); }, ), ), @@ -53,6 +54,8 @@ class AppHeader extends StatelessWidget { // icon: const Icon(Icons.add), // onPressed: () { // debugPrint('add view'); + // FlowyOverlay.of(context) + // .insert(widget: Text('test'), identifier: 'identifier'); // }, // ), PopupMenuButton( diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pb.dart index eb5363c524..f1045271b2 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pb.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pb.dart @@ -156,7 +156,7 @@ class App extends $pb.GeneratedMessage { ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'workspaceId') ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'desc') - ..aOM<$0.RepeatedView>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'views', subBuilder: $0.RepeatedView.create) + ..aOM<$0.RepeatedView>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'belongings', subBuilder: $0.RepeatedView.create) ..aInt64(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'version') ..hasRequiredFields = false ; @@ -167,7 +167,7 @@ class App extends $pb.GeneratedMessage { $core.String? workspaceId, $core.String? name, $core.String? desc, - $0.RepeatedView? views, + $0.RepeatedView? belongings, $fixnum.Int64? version, }) { final _result = create(); @@ -183,8 +183,8 @@ class App extends $pb.GeneratedMessage { if (desc != null) { _result.desc = desc; } - if (views != null) { - _result.views = views; + if (belongings != null) { + _result.belongings = belongings; } if (version != null) { _result.version = version; @@ -249,15 +249,15 @@ class App extends $pb.GeneratedMessage { void clearDesc() => clearField(4); @$pb.TagNumber(5) - $0.RepeatedView get views => $_getN(4); + $0.RepeatedView get belongings => $_getN(4); @$pb.TagNumber(5) - set views($0.RepeatedView v) { setField(5, v); } + set belongings($0.RepeatedView v) { setField(5, v); } @$pb.TagNumber(5) - $core.bool hasViews() => $_has(4); + $core.bool hasBelongings() => $_has(4); @$pb.TagNumber(5) - void clearViews() => clearField(5); + void clearBelongings() => clearField(5); @$pb.TagNumber(5) - $0.RepeatedView ensureViews() => $_ensure(4); + $0.RepeatedView ensureBelongings() => $_ensure(4); @$pb.TagNumber(6) $fixnum.Int64 get version => $_getI64(5); diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pbjson.dart index 9c25d387f9..749879c1e8 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pbjson.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pbjson.dart @@ -39,13 +39,13 @@ const App$json = const { const {'1': 'workspace_id', '3': 2, '4': 1, '5': 9, '10': 'workspaceId'}, const {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'}, const {'1': 'desc', '3': 4, '4': 1, '5': 9, '10': 'desc'}, - const {'1': 'views', '3': 5, '4': 1, '5': 11, '6': '.RepeatedView', '10': 'views'}, + const {'1': 'belongings', '3': 5, '4': 1, '5': 11, '6': '.RepeatedView', '10': 'belongings'}, const {'1': 'version', '3': 6, '4': 1, '5': 3, '10': 'version'}, ], }; /// Descriptor for `App`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List appDescriptor = $convert.base64Decode('CgNBcHASDgoCaWQYASABKAlSAmlkEiEKDHdvcmtzcGFjZV9pZBgCIAEoCVILd29ya3NwYWNlSWQSEgoEbmFtZRgDIAEoCVIEbmFtZRISCgRkZXNjGAQgASgJUgRkZXNjEiMKBXZpZXdzGAUgASgLMg0uUmVwZWF0ZWRWaWV3UgV2aWV3cxIYCgd2ZXJzaW9uGAYgASgDUgd2ZXJzaW9u'); +final $typed_data.Uint8List appDescriptor = $convert.base64Decode('CgNBcHASDgoCaWQYASABKAlSAmlkEiEKDHdvcmtzcGFjZV9pZBgCIAEoCVILd29ya3NwYWNlSWQSEgoEbmFtZRgDIAEoCVIEbmFtZRISCgRkZXNjGAQgASgJUgRkZXNjEi0KCmJlbG9uZ2luZ3MYBSABKAsyDS5SZXBlYXRlZFZpZXdSCmJlbG9uZ2luZ3MSGAoHdmVyc2lvbhgGIAEoA1IHdmVyc2lvbg=='); @$core.Deprecated('Use repeatedAppDescriptor instead') const RepeatedApp$json = const { '1': 'RepeatedApp', diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pb.dart index 1b0eee47b3..b1471f48db 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pb.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pb.dart @@ -12,7 +12,7 @@ import 'package:protobuf/protobuf.dart' as $pb; class QueryAppRequest extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'QueryAppRequest', createEmptyInstance: create) ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'appId') - ..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'readViews') + ..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'readBelongings') ..aOB(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isTrash') ..hasRequiredFields = false ; @@ -20,15 +20,15 @@ class QueryAppRequest extends $pb.GeneratedMessage { QueryAppRequest._() : super(); factory QueryAppRequest({ $core.String? appId, - $core.bool? readViews, + $core.bool? readBelongings, $core.bool? isTrash, }) { final _result = create(); if (appId != null) { _result.appId = appId; } - if (readViews != null) { - _result.readViews = readViews; + if (readBelongings != null) { + _result.readBelongings = readBelongings; } if (isTrash != null) { _result.isTrash = isTrash; @@ -66,13 +66,13 @@ class QueryAppRequest extends $pb.GeneratedMessage { void clearAppId() => clearField(1); @$pb.TagNumber(2) - $core.bool get readViews => $_getBF(1); + $core.bool get readBelongings => $_getBF(1); @$pb.TagNumber(2) - set readViews($core.bool v) { $_setBool(1, v); } + set readBelongings($core.bool v) { $_setBool(1, v); } @$pb.TagNumber(2) - $core.bool hasReadViews() => $_has(1); + $core.bool hasReadBelongings() => $_has(1); @$pb.TagNumber(2) - void clearReadViews() => clearField(2); + void clearReadBelongings() => clearField(2); @$pb.TagNumber(3) $core.bool get isTrash => $_getBF(2); diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pbjson.dart index a976c650a3..b7c1c9dc56 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pbjson.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pbjson.dart @@ -13,10 +13,10 @@ const QueryAppRequest$json = const { '1': 'QueryAppRequest', '2': const [ const {'1': 'app_id', '3': 1, '4': 1, '5': 9, '10': 'appId'}, - const {'1': 'read_views', '3': 2, '4': 1, '5': 8, '10': 'readViews'}, + const {'1': 'read_belongings', '3': 2, '4': 1, '5': 8, '10': 'readBelongings'}, const {'1': 'is_trash', '3': 3, '4': 1, '5': 8, '10': 'isTrash'}, ], }; /// Descriptor for `QueryAppRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List queryAppRequestDescriptor = $convert.base64Decode('Cg9RdWVyeUFwcFJlcXVlc3QSFQoGYXBwX2lkGAEgASgJUgVhcHBJZBIdCgpyZWFkX3ZpZXdzGAIgASgIUglyZWFkVmlld3MSGQoIaXNfdHJhc2gYAyABKAhSB2lzVHJhc2g='); +final $typed_data.Uint8List queryAppRequestDescriptor = $convert.base64Decode('Cg9RdWVyeUFwcFJlcXVlc3QSFQoGYXBwX2lkGAEgASgJUgVhcHBJZBInCg9yZWFkX2JlbG9uZ2luZ3MYAiABKAhSDnJlYWRCZWxvbmdpbmdzEhkKCGlzX3RyYXNoGAMgASgIUgdpc1RyYXNo'); diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/observable.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/observable.pbenum.dart index 5a73da2f00..de5c6943af 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/observable.pbenum.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/observable.pbenum.dart @@ -11,19 +11,27 @@ import 'package:protobuf/protobuf.dart' as $pb; class WorkspaceObservable extends $pb.ProtobufEnum { static const WorkspaceObservable Unknown = WorkspaceObservable._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'Unknown'); - static const WorkspaceObservable WorkspaceUpdateDesc = WorkspaceObservable._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceUpdateDesc'); - static const WorkspaceObservable WorkspaceAddApp = WorkspaceObservable._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceAddApp'); - static const WorkspaceObservable AppUpdateDesc = WorkspaceObservable._(20, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppUpdateDesc'); - static const WorkspaceObservable AppAddView = WorkspaceObservable._(21, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppAddView'); - static const WorkspaceObservable ViewUpdateDesc = WorkspaceObservable._(30, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewUpdateDesc'); + static const WorkspaceObservable UserCreateWorkspace = WorkspaceObservable._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserCreateWorkspace'); + static const WorkspaceObservable UserDeleteWorkspace = WorkspaceObservable._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserDeleteWorkspace'); + static const WorkspaceObservable WorkspaceUpdated = WorkspaceObservable._(12, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceUpdated'); + static const WorkspaceObservable WorkspaceCreateApp = WorkspaceObservable._(13, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceCreateApp'); + static const WorkspaceObservable WorkspaceDeleteApp = WorkspaceObservable._(14, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceDeleteApp'); + static const WorkspaceObservable AppUpdated = WorkspaceObservable._(21, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppUpdated'); + static const WorkspaceObservable AppCreateView = WorkspaceObservable._(23, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppCreateView'); + static const WorkspaceObservable AppDeleteView = WorkspaceObservable._(24, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppDeleteView'); + static const WorkspaceObservable ViewUpdated = WorkspaceObservable._(31, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewUpdated'); static const $core.List values = [ Unknown, - WorkspaceUpdateDesc, - WorkspaceAddApp, - AppUpdateDesc, - AppAddView, - ViewUpdateDesc, + UserCreateWorkspace, + UserDeleteWorkspace, + WorkspaceUpdated, + WorkspaceCreateApp, + WorkspaceDeleteApp, + AppUpdated, + AppCreateView, + AppDeleteView, + ViewUpdated, ]; static final $core.Map<$core.int, WorkspaceObservable> _byValue = $pb.ProtobufEnum.initByValue(values); diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/observable.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/observable.pbjson.dart index d9d9cc02a8..987a1ddbdd 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/observable.pbjson.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/observable.pbjson.dart @@ -13,13 +13,17 @@ const WorkspaceObservable$json = const { '1': 'WorkspaceObservable', '2': const [ const {'1': 'Unknown', '2': 0}, - const {'1': 'WorkspaceUpdateDesc', '2': 10}, - const {'1': 'WorkspaceAddApp', '2': 11}, - const {'1': 'AppUpdateDesc', '2': 20}, - const {'1': 'AppAddView', '2': 21}, - const {'1': 'ViewUpdateDesc', '2': 30}, + const {'1': 'UserCreateWorkspace', '2': 10}, + const {'1': 'UserDeleteWorkspace', '2': 11}, + const {'1': 'WorkspaceUpdated', '2': 12}, + const {'1': 'WorkspaceCreateApp', '2': 13}, + const {'1': 'WorkspaceDeleteApp', '2': 14}, + const {'1': 'AppUpdated', '2': 21}, + const {'1': 'AppCreateView', '2': 23}, + const {'1': 'AppDeleteView', '2': 24}, + const {'1': 'ViewUpdated', '2': 31}, ], }; /// Descriptor for `WorkspaceObservable`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List workspaceObservableDescriptor = $convert.base64Decode('ChNXb3Jrc3BhY2VPYnNlcnZhYmxlEgsKB1Vua25vd24QABIXChNXb3Jrc3BhY2VVcGRhdGVEZXNjEAoSEwoPV29ya3NwYWNlQWRkQXBwEAsSEQoNQXBwVXBkYXRlRGVzYxAUEg4KCkFwcEFkZFZpZXcQFRISCg5WaWV3VXBkYXRlRGVzYxAe'); +final $typed_data.Uint8List workspaceObservableDescriptor = $convert.base64Decode('ChNXb3Jrc3BhY2VPYnNlcnZhYmxlEgsKB1Vua25vd24QABIXChNVc2VyQ3JlYXRlV29ya3NwYWNlEAoSFwoTVXNlckRlbGV0ZVdvcmtzcGFjZRALEhQKEFdvcmtzcGFjZVVwZGF0ZWQQDBIWChJXb3Jrc3BhY2VDcmVhdGVBcHAQDRIWChJXb3Jrc3BhY2VEZWxldGVBcHAQDhIOCgpBcHBVcGRhdGVkEBUSEQoNQXBwQ3JlYXRlVmlldxAXEhEKDUFwcERlbGV0ZVZpZXcQGBIPCgtWaWV3VXBkYXRlZBAf'); diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pb.dart index 2cd7c398d8..8605133f64 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pb.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pb.dart @@ -138,6 +138,7 @@ class View extends $pb.GeneratedMessage { ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'desc') ..e(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'viewType', $pb.PbFieldType.OE, defaultOrMaker: ViewType.Blank, valueOf: ViewType.valueOf, enumValues: ViewType.values) ..aInt64(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'version') + ..aOM(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'belongings', subBuilder: RepeatedView.create) ..hasRequiredFields = false ; @@ -149,6 +150,7 @@ class View extends $pb.GeneratedMessage { $core.String? desc, ViewType? viewType, $fixnum.Int64? version, + RepeatedView? belongings, }) { final _result = create(); if (id != null) { @@ -169,6 +171,9 @@ class View extends $pb.GeneratedMessage { if (version != null) { _result.version = version; } + if (belongings != null) { + _result.belongings = belongings; + } return _result; } factory View.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); @@ -245,6 +250,17 @@ class View extends $pb.GeneratedMessage { $core.bool hasVersion() => $_has(5); @$pb.TagNumber(6) void clearVersion() => clearField(6); + + @$pb.TagNumber(7) + RepeatedView get belongings => $_getN(6); + @$pb.TagNumber(7) + set belongings(RepeatedView v) { setField(7, v); } + @$pb.TagNumber(7) + $core.bool hasBelongings() => $_has(6); + @$pb.TagNumber(7) + void clearBelongings() => clearField(7); + @$pb.TagNumber(7) + RepeatedView ensureBelongings() => $_ensure(6); } class RepeatedView extends $pb.GeneratedMessage { diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pbjson.dart index 7dbabe7548..da5def62e6 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pbjson.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pbjson.dart @@ -46,11 +46,12 @@ const View$json = const { const {'1': 'desc', '3': 4, '4': 1, '5': 9, '10': 'desc'}, const {'1': 'view_type', '3': 5, '4': 1, '5': 14, '6': '.ViewType', '10': 'viewType'}, const {'1': 'version', '3': 6, '4': 1, '5': 3, '10': 'version'}, + const {'1': 'belongings', '3': 7, '4': 1, '5': 11, '6': '.RepeatedView', '10': 'belongings'}, ], }; /// Descriptor for `View`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List viewDescriptor = $convert.base64Decode('CgRWaWV3Eg4KAmlkGAEgASgJUgJpZBIgCgxiZWxvbmdfdG9faWQYAiABKAlSCmJlbG9uZ1RvSWQSEgoEbmFtZRgDIAEoCVIEbmFtZRISCgRkZXNjGAQgASgJUgRkZXNjEiYKCXZpZXdfdHlwZRgFIAEoDjIJLlZpZXdUeXBlUgh2aWV3VHlwZRIYCgd2ZXJzaW9uGAYgASgDUgd2ZXJzaW9u'); +final $typed_data.Uint8List viewDescriptor = $convert.base64Decode('CgRWaWV3Eg4KAmlkGAEgASgJUgJpZBIgCgxiZWxvbmdfdG9faWQYAiABKAlSCmJlbG9uZ1RvSWQSEgoEbmFtZRgDIAEoCVIEbmFtZRISCgRkZXNjGAQgASgJUgRkZXNjEiYKCXZpZXdfdHlwZRgFIAEoDjIJLlZpZXdUeXBlUgh2aWV3VHlwZRIYCgd2ZXJzaW9uGAYgASgDUgd2ZXJzaW9uEi0KCmJlbG9uZ2luZ3MYByABKAsyDS5SZXBlYXRlZFZpZXdSCmJlbG9uZ2luZ3M='); @$core.Deprecated('Use repeatedViewDescriptor instead') const RepeatedView$json = const { '1': 'RepeatedView', diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pb.dart index f37fd6111f..7ec02f603f 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pb.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pb.dart @@ -13,6 +13,7 @@ class QueryViewRequest extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'QueryViewRequest', createEmptyInstance: create) ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'viewId') ..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isTrash') + ..aOB(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'readBelongings') ..hasRequiredFields = false ; @@ -20,6 +21,7 @@ class QueryViewRequest extends $pb.GeneratedMessage { factory QueryViewRequest({ $core.String? viewId, $core.bool? isTrash, + $core.bool? readBelongings, }) { final _result = create(); if (viewId != null) { @@ -28,6 +30,9 @@ class QueryViewRequest extends $pb.GeneratedMessage { if (isTrash != null) { _result.isTrash = isTrash; } + if (readBelongings != null) { + _result.readBelongings = readBelongings; + } return _result; } factory QueryViewRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); @@ -68,5 +73,14 @@ class QueryViewRequest extends $pb.GeneratedMessage { $core.bool hasIsTrash() => $_has(1); @$pb.TagNumber(2) void clearIsTrash() => clearField(2); + + @$pb.TagNumber(3) + $core.bool get readBelongings => $_getBF(2); + @$pb.TagNumber(3) + set readBelongings($core.bool v) { $_setBool(2, v); } + @$pb.TagNumber(3) + $core.bool hasReadBelongings() => $_has(2); + @$pb.TagNumber(3) + void clearReadBelongings() => clearField(3); } diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pbjson.dart index dc55bdeddb..6c18f0dc89 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pbjson.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pbjson.dart @@ -14,8 +14,9 @@ const QueryViewRequest$json = const { '2': const [ const {'1': 'view_id', '3': 1, '4': 1, '5': 9, '10': 'viewId'}, const {'1': 'is_trash', '3': 2, '4': 1, '5': 8, '10': 'isTrash'}, + const {'1': 'read_belongings', '3': 3, '4': 1, '5': 8, '10': 'readBelongings'}, ], }; /// Descriptor for `QueryViewRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List queryViewRequestDescriptor = $convert.base64Decode('ChBRdWVyeVZpZXdSZXF1ZXN0EhcKB3ZpZXdfaWQYASABKAlSBnZpZXdJZBIZCghpc190cmFzaBgCIAEoCFIHaXNUcmFzaA=='); +final $typed_data.Uint8List queryViewRequestDescriptor = $convert.base64Decode('ChBRdWVyeVZpZXdSZXF1ZXN0EhcKB3ZpZXdfaWQYASABKAlSBnZpZXdJZBIZCghpc190cmFzaBgCIAEoCFIHaXNUcmFzaBInCg9yZWFkX2JlbG9uZ2luZ3MYAyABKAhSDnJlYWRCZWxvbmdpbmdz'); diff --git a/rust-lib/flowy-workspace/src/entities/app/app_create.rs b/rust-lib/flowy-workspace/src/entities/app/app_create.rs index 0c19ed952d..53efacfbc6 100644 --- a/rust-lib/flowy-workspace/src/entities/app/app_create.rs +++ b/rust-lib/flowy-workspace/src/entities/app/app_create.rs @@ -81,7 +81,7 @@ pub struct App { pub desc: String, #[pb(index = 5)] - pub views: RepeatedView, + pub belongings: RepeatedView, #[pb(index = 6)] pub version: i64, diff --git a/rust-lib/flowy-workspace/src/entities/app/app_query.rs b/rust-lib/flowy-workspace/src/entities/app/app_query.rs index 27f5371b9c..432ee5b545 100644 --- a/rust-lib/flowy-workspace/src/entities/app/app_query.rs +++ b/rust-lib/flowy-workspace/src/entities/app/app_query.rs @@ -8,7 +8,7 @@ pub struct QueryAppRequest { pub app_id: String, #[pb(index = 2)] - pub read_views: bool, + pub read_belongings: bool, #[pb(index = 3)] pub is_trash: bool, @@ -18,13 +18,13 @@ impl QueryAppRequest { pub fn new(app_id: &str) -> Self { QueryAppRequest { app_id: app_id.to_string(), - read_views: false, + read_belongings: false, is_trash: false, } } pub fn set_read_views(mut self, read_views: bool) -> Self { - self.read_views = read_views; + self.read_belongings = read_views; self } @@ -36,7 +36,7 @@ impl QueryAppRequest { pub struct QueryAppParams { pub app_id: String, - pub read_views: bool, + pub read_belongings: bool, pub is_trash: bool, } @@ -50,7 +50,7 @@ impl TryInto for QueryAppRequest { Ok(QueryAppParams { app_id, - read_views: self.read_views, + read_belongings: self.read_belongings, is_trash: self.is_trash, }) } diff --git a/rust-lib/flowy-workspace/src/entities/view/view_create.rs b/rust-lib/flowy-workspace/src/entities/view/view_create.rs index 2866a363e8..1697b82a05 100644 --- a/rust-lib/flowy-workspace/src/entities/view/view_create.rs +++ b/rust-lib/flowy-workspace/src/entities/view/view_create.rs @@ -98,6 +98,9 @@ pub struct View { #[pb(index = 6)] pub version: i64, + + #[pb(index = 7)] + pub belongings: RepeatedView, } #[derive(PartialEq, Debug, Default, ProtoBuf)] diff --git a/rust-lib/flowy-workspace/src/entities/view/view_query.rs b/rust-lib/flowy-workspace/src/entities/view/view_query.rs index e0b6aae8f9..4243421461 100644 --- a/rust-lib/flowy-workspace/src/entities/view/view_query.rs +++ b/rust-lib/flowy-workspace/src/entities/view/view_query.rs @@ -12,6 +12,9 @@ pub struct QueryViewRequest { #[pb(index = 2)] pub is_trash: bool, + + #[pb(index = 3)] + pub read_belongings: bool, } impl QueryViewRequest { @@ -19,6 +22,7 @@ impl QueryViewRequest { Self { view_id: view_id.to_owned(), is_trash: false, + read_belongings: false, } } @@ -31,6 +35,7 @@ impl QueryViewRequest { pub struct QueryViewParams { pub view_id: String, pub is_trash: bool, + pub read_belongings: bool, } impl TryInto for QueryViewRequest { @@ -44,6 +49,7 @@ impl TryInto for QueryViewRequest { Ok(QueryViewParams { view_id, is_trash: self.is_trash, + read_belongings: self.read_belongings, }) } } diff --git a/rust-lib/flowy-workspace/src/handlers/app_handler.rs b/rust-lib/flowy-workspace/src/handlers/app_handler.rs index c34a2848ac..3d5c9008d0 100644 --- a/rust-lib/flowy-workspace/src/handlers/app_handler.rs +++ b/rust-lib/flowy-workspace/src/handlers/app_handler.rs @@ -59,9 +59,9 @@ pub async fn read_app( let mut app = app_controller .read_app(¶ms.app_id, params.is_trash) .await?; - if params.read_views { + if params.read_belongings { let views = view_controller.read_views_belong_to(¶ms.app_id).await?; - app.views = RepeatedView { items: views }; + app.belongings = RepeatedView { items: views }; } response_ok(app) diff --git a/rust-lib/flowy-workspace/src/handlers/view_handler.rs b/rust-lib/flowy-workspace/src/handlers/view_handler.rs index 5d1145f853..0dc6bf86f1 100644 --- a/rust-lib/flowy-workspace/src/handlers/view_handler.rs +++ b/rust-lib/flowy-workspace/src/handlers/view_handler.rs @@ -6,6 +6,7 @@ use crate::{ DeleteViewRequest, QueryViewParams, QueryViewRequest, + RepeatedView, UpdateViewParams, UpdateViewRequest, View, @@ -32,10 +33,15 @@ pub async fn read_view( controller: Unit>, ) -> ResponseResult { let params: QueryViewParams = data.into_inner().try_into()?; - let view = controller + let mut view = controller .read_view(¶ms.view_id, params.is_trash) .await?; + if params.read_belongings { + let views = controller.read_views_belong_to(¶ms.view_id).await?; + view.belongings = RepeatedView { items: views } + } + response_ok(view) } diff --git a/rust-lib/flowy-workspace/src/observable/observable.rs b/rust-lib/flowy-workspace/src/observable/observable.rs index 0344226b00..82db0f5f99 100644 --- a/rust-lib/flowy-workspace/src/observable/observable.rs +++ b/rust-lib/flowy-workspace/src/observable/observable.rs @@ -7,13 +7,18 @@ const OBSERVABLE_CATEGORY: &'static str = "Workspace"; pub(crate) enum WorkspaceObservable { Unknown = 0, - WorkspaceUpdateDesc = 10, - WorkspaceAddApp = 11, + UserCreateWorkspace = 10, + UserDeleteWorkspace = 11, - AppUpdateDesc = 20, - AppAddView = 21, + WorkspaceUpdated = 12, + WorkspaceCreateApp = 13, + WorkspaceDeleteApp = 14, - ViewUpdateDesc = 30, + AppUpdated = 21, + AppCreateView = 23, + AppDeleteView = 24, + + ViewUpdated = 31, } impl std::default::Default for WorkspaceObservable { diff --git a/rust-lib/flowy-workspace/src/protobuf/model/app_create.rs b/rust-lib/flowy-workspace/src/protobuf/model/app_create.rs index 2793e812de..201fab2d6d 100644 --- a/rust-lib/flowy-workspace/src/protobuf/model/app_create.rs +++ b/rust-lib/flowy-workspace/src/protobuf/model/app_create.rs @@ -489,7 +489,7 @@ pub struct App { pub workspace_id: ::std::string::String, pub name: ::std::string::String, pub desc: ::std::string::String, - pub views: ::protobuf::SingularPtrField, + pub belongings: ::protobuf::SingularPtrField, pub version: i64, // special fields pub unknown_fields: ::protobuf::UnknownFields, @@ -611,37 +611,37 @@ impl App { ::std::mem::replace(&mut self.desc, ::std::string::String::new()) } - // .RepeatedView views = 5; + // .RepeatedView belongings = 5; - pub fn get_views(&self) -> &super::view_create::RepeatedView { - self.views.as_ref().unwrap_or_else(|| ::default_instance()) + pub fn get_belongings(&self) -> &super::view_create::RepeatedView { + self.belongings.as_ref().unwrap_or_else(|| ::default_instance()) } - pub fn clear_views(&mut self) { - self.views.clear(); + pub fn clear_belongings(&mut self) { + self.belongings.clear(); } - pub fn has_views(&self) -> bool { - self.views.is_some() + pub fn has_belongings(&self) -> bool { + self.belongings.is_some() } // Param is passed by value, moved - pub fn set_views(&mut self, v: super::view_create::RepeatedView) { - self.views = ::protobuf::SingularPtrField::some(v); + pub fn set_belongings(&mut self, v: super::view_create::RepeatedView) { + self.belongings = ::protobuf::SingularPtrField::some(v); } // Mutable pointer to the field. // If field is not initialized, it is initialized with default value first. - pub fn mut_views(&mut self) -> &mut super::view_create::RepeatedView { - if self.views.is_none() { - self.views.set_default(); + pub fn mut_belongings(&mut self) -> &mut super::view_create::RepeatedView { + if self.belongings.is_none() { + self.belongings.set_default(); } - self.views.as_mut().unwrap() + self.belongings.as_mut().unwrap() } // Take field - pub fn take_views(&mut self) -> super::view_create::RepeatedView { - self.views.take().unwrap_or_else(|| super::view_create::RepeatedView::new()) + pub fn take_belongings(&mut self) -> super::view_create::RepeatedView { + self.belongings.take().unwrap_or_else(|| super::view_create::RepeatedView::new()) } // int64 version = 6; @@ -662,7 +662,7 @@ impl App { impl ::protobuf::Message for App { fn is_initialized(&self) -> bool { - for v in &self.views { + for v in &self.belongings { if !v.is_initialized() { return false; } @@ -687,7 +687,7 @@ impl ::protobuf::Message for App { ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.desc)?; }, 5 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.views)?; + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.belongings)?; }, 6 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { @@ -720,7 +720,7 @@ impl ::protobuf::Message for App { if !self.desc.is_empty() { my_size += ::protobuf::rt::string_size(4, &self.desc); } - if let Some(ref v) = self.views.as_ref() { + if let Some(ref v) = self.belongings.as_ref() { let len = v.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; } @@ -745,7 +745,7 @@ impl ::protobuf::Message for App { if !self.desc.is_empty() { os.write_string(4, &self.desc)?; } - if let Some(ref v) = self.views.as_ref() { + if let Some(ref v) = self.belongings.as_ref() { os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; @@ -812,9 +812,9 @@ impl ::protobuf::Message for App { |m: &mut App| { &mut m.desc }, )); fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "views", - |m: &App| { &m.views }, - |m: &mut App| { &mut m.views }, + "belongings", + |m: &App| { &m.belongings }, + |m: &mut App| { &mut m.belongings }, )); fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( "version", @@ -841,7 +841,7 @@ impl ::protobuf::Clear for App { self.workspace_id.clear(); self.name.clear(); self.desc.clear(); - self.views.clear(); + self.belongings.clear(); self.version = 0; self.unknown_fields.clear(); } @@ -1031,52 +1031,52 @@ static file_descriptor_proto_data: &'static [u8] = b"\ \x12\n\x04name\x18\x02\x20\x01(\tR\x04name\x12\x12\n\x04desc\x18\x03\x20\ \x01(\tR\x04desc\x12,\n\x0bcolor_style\x18\x04\x20\x01(\x0b2\x0b.ColorSt\ yleR\ncolorStyle\"-\n\nColorStyle\x12\x1f\n\x0btheme_color\x18\x01\x20\ - \x01(\tR\nthemeColor\"\x9f\x01\n\x03App\x12\x0e\n\x02id\x18\x01\x20\x01(\ + \x01(\tR\nthemeColor\"\xa9\x01\n\x03App\x12\x0e\n\x02id\x18\x01\x20\x01(\ \tR\x02id\x12!\n\x0cworkspace_id\x18\x02\x20\x01(\tR\x0bworkspaceId\x12\ \x12\n\x04name\x18\x03\x20\x01(\tR\x04name\x12\x12\n\x04desc\x18\x04\x20\ - \x01(\tR\x04desc\x12#\n\x05views\x18\x05\x20\x01(\x0b2\r.RepeatedViewR\ - \x05views\x12\x18\n\x07version\x18\x06\x20\x01(\x03R\x07version\")\n\x0b\ - RepeatedApp\x12\x1a\n\x05items\x18\x01\x20\x03(\x0b2\x04.AppR\x05itemsJ\ - \x9f\x06\n\x06\x12\x04\0\0\x16\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\t\n\ - \x02\x03\0\x12\x03\x01\0\x1b\n\n\n\x02\x04\0\x12\x04\x03\0\x08\x01\n\n\n\ - \x03\x04\0\x01\x12\x03\x03\x08\x18\n\x0b\n\x04\x04\0\x02\0\x12\x03\x04\ - \x04\x1c\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x04\x04\n\n\x0c\n\x05\x04\0\ - \x02\0\x01\x12\x03\x04\x0b\x17\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x04\ - \x1a\x1b\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x05\x04\x14\n\x0c\n\x05\x04\0\ - \x02\x01\x05\x12\x03\x05\x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x05\ - \x0b\x0f\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x05\x12\x13\n\x0b\n\x04\ - \x04\0\x02\x02\x12\x03\x06\x04\x14\n\x0c\n\x05\x04\0\x02\x02\x05\x12\x03\ - \x06\x04\n\n\x0c\n\x05\x04\0\x02\x02\x01\x12\x03\x06\x0b\x0f\n\x0c\n\x05\ - \x04\0\x02\x02\x03\x12\x03\x06\x12\x13\n\x0b\n\x04\x04\0\x02\x03\x12\x03\ - \x07\x04\x1f\n\x0c\n\x05\x04\0\x02\x03\x06\x12\x03\x07\x04\x0e\n\x0c\n\ - \x05\x04\0\x02\x03\x01\x12\x03\x07\x0f\x1a\n\x0c\n\x05\x04\0\x02\x03\x03\ - \x12\x03\x07\x1d\x1e\n\n\n\x02\x04\x01\x12\x04\t\0\x0b\x01\n\n\n\x03\x04\ - \x01\x01\x12\x03\t\x08\x12\n\x0b\n\x04\x04\x01\x02\0\x12\x03\n\x04\x1b\n\ - \x0c\n\x05\x04\x01\x02\0\x05\x12\x03\n\x04\n\n\x0c\n\x05\x04\x01\x02\0\ - \x01\x12\x03\n\x0b\x16\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\n\x19\x1a\n\ - \n\n\x02\x04\x02\x12\x04\x0c\0\x13\x01\n\n\n\x03\x04\x02\x01\x12\x03\x0c\ - \x08\x0b\n\x0b\n\x04\x04\x02\x02\0\x12\x03\r\x04\x12\n\x0c\n\x05\x04\x02\ - \x02\0\x05\x12\x03\r\x04\n\n\x0c\n\x05\x04\x02\x02\0\x01\x12\x03\r\x0b\r\ - \n\x0c\n\x05\x04\x02\x02\0\x03\x12\x03\r\x10\x11\n\x0b\n\x04\x04\x02\x02\ - \x01\x12\x03\x0e\x04\x1c\n\x0c\n\x05\x04\x02\x02\x01\x05\x12\x03\x0e\x04\ - \n\n\x0c\n\x05\x04\x02\x02\x01\x01\x12\x03\x0e\x0b\x17\n\x0c\n\x05\x04\ - \x02\x02\x01\x03\x12\x03\x0e\x1a\x1b\n\x0b\n\x04\x04\x02\x02\x02\x12\x03\ - \x0f\x04\x14\n\x0c\n\x05\x04\x02\x02\x02\x05\x12\x03\x0f\x04\n\n\x0c\n\ - \x05\x04\x02\x02\x02\x01\x12\x03\x0f\x0b\x0f\n\x0c\n\x05\x04\x02\x02\x02\ - \x03\x12\x03\x0f\x12\x13\n\x0b\n\x04\x04\x02\x02\x03\x12\x03\x10\x04\x14\ - \n\x0c\n\x05\x04\x02\x02\x03\x05\x12\x03\x10\x04\n\n\x0c\n\x05\x04\x02\ - \x02\x03\x01\x12\x03\x10\x0b\x0f\n\x0c\n\x05\x04\x02\x02\x03\x03\x12\x03\ - \x10\x12\x13\n\x0b\n\x04\x04\x02\x02\x04\x12\x03\x11\x04\x1b\n\x0c\n\x05\ - \x04\x02\x02\x04\x06\x12\x03\x11\x04\x10\n\x0c\n\x05\x04\x02\x02\x04\x01\ - \x12\x03\x11\x11\x16\n\x0c\n\x05\x04\x02\x02\x04\x03\x12\x03\x11\x19\x1a\ - \n\x0b\n\x04\x04\x02\x02\x05\x12\x03\x12\x04\x16\n\x0c\n\x05\x04\x02\x02\ - \x05\x05\x12\x03\x12\x04\t\n\x0c\n\x05\x04\x02\x02\x05\x01\x12\x03\x12\n\ - \x11\n\x0c\n\x05\x04\x02\x02\x05\x03\x12\x03\x12\x14\x15\n\n\n\x02\x04\ - \x03\x12\x04\x14\0\x16\x01\n\n\n\x03\x04\x03\x01\x12\x03\x14\x08\x13\n\ - \x0b\n\x04\x04\x03\x02\0\x12\x03\x15\x04\x1b\n\x0c\n\x05\x04\x03\x02\0\ - \x04\x12\x03\x15\x04\x0c\n\x0c\n\x05\x04\x03\x02\0\x06\x12\x03\x15\r\x10\ - \n\x0c\n\x05\x04\x03\x02\0\x01\x12\x03\x15\x11\x16\n\x0c\n\x05\x04\x03\ - \x02\0\x03\x12\x03\x15\x19\x1ab\x06proto3\ + \x01(\tR\x04desc\x12-\n\nbelongings\x18\x05\x20\x01(\x0b2\r.RepeatedView\ + R\nbelongings\x12\x18\n\x07version\x18\x06\x20\x01(\x03R\x07version\")\n\ + \x0bRepeatedApp\x12\x1a\n\x05items\x18\x01\x20\x03(\x0b2\x04.AppR\x05ite\ + msJ\x9f\x06\n\x06\x12\x04\0\0\x16\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\ + \t\n\x02\x03\0\x12\x03\x01\0\x1b\n\n\n\x02\x04\0\x12\x04\x03\0\x08\x01\n\ + \n\n\x03\x04\0\x01\x12\x03\x03\x08\x18\n\x0b\n\x04\x04\0\x02\0\x12\x03\ + \x04\x04\x1c\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x04\x04\n\n\x0c\n\x05\ + \x04\0\x02\0\x01\x12\x03\x04\x0b\x17\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\ + \x04\x1a\x1b\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x05\x04\x14\n\x0c\n\x05\ + \x04\0\x02\x01\x05\x12\x03\x05\x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\ + \x03\x05\x0b\x0f\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x05\x12\x13\n\x0b\ + \n\x04\x04\0\x02\x02\x12\x03\x06\x04\x14\n\x0c\n\x05\x04\0\x02\x02\x05\ + \x12\x03\x06\x04\n\n\x0c\n\x05\x04\0\x02\x02\x01\x12\x03\x06\x0b\x0f\n\ + \x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x06\x12\x13\n\x0b\n\x04\x04\0\x02\ + \x03\x12\x03\x07\x04\x1f\n\x0c\n\x05\x04\0\x02\x03\x06\x12\x03\x07\x04\ + \x0e\n\x0c\n\x05\x04\0\x02\x03\x01\x12\x03\x07\x0f\x1a\n\x0c\n\x05\x04\0\ + \x02\x03\x03\x12\x03\x07\x1d\x1e\n\n\n\x02\x04\x01\x12\x04\t\0\x0b\x01\n\ + \n\n\x03\x04\x01\x01\x12\x03\t\x08\x12\n\x0b\n\x04\x04\x01\x02\0\x12\x03\ + \n\x04\x1b\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03\n\x04\n\n\x0c\n\x05\x04\ + \x01\x02\0\x01\x12\x03\n\x0b\x16\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\n\ + \x19\x1a\n\n\n\x02\x04\x02\x12\x04\x0c\0\x13\x01\n\n\n\x03\x04\x02\x01\ + \x12\x03\x0c\x08\x0b\n\x0b\n\x04\x04\x02\x02\0\x12\x03\r\x04\x12\n\x0c\n\ + \x05\x04\x02\x02\0\x05\x12\x03\r\x04\n\n\x0c\n\x05\x04\x02\x02\0\x01\x12\ + \x03\r\x0b\r\n\x0c\n\x05\x04\x02\x02\0\x03\x12\x03\r\x10\x11\n\x0b\n\x04\ + \x04\x02\x02\x01\x12\x03\x0e\x04\x1c\n\x0c\n\x05\x04\x02\x02\x01\x05\x12\ + \x03\x0e\x04\n\n\x0c\n\x05\x04\x02\x02\x01\x01\x12\x03\x0e\x0b\x17\n\x0c\ + \n\x05\x04\x02\x02\x01\x03\x12\x03\x0e\x1a\x1b\n\x0b\n\x04\x04\x02\x02\ + \x02\x12\x03\x0f\x04\x14\n\x0c\n\x05\x04\x02\x02\x02\x05\x12\x03\x0f\x04\ + \n\n\x0c\n\x05\x04\x02\x02\x02\x01\x12\x03\x0f\x0b\x0f\n\x0c\n\x05\x04\ + \x02\x02\x02\x03\x12\x03\x0f\x12\x13\n\x0b\n\x04\x04\x02\x02\x03\x12\x03\ + \x10\x04\x14\n\x0c\n\x05\x04\x02\x02\x03\x05\x12\x03\x10\x04\n\n\x0c\n\ + \x05\x04\x02\x02\x03\x01\x12\x03\x10\x0b\x0f\n\x0c\n\x05\x04\x02\x02\x03\ + \x03\x12\x03\x10\x12\x13\n\x0b\n\x04\x04\x02\x02\x04\x12\x03\x11\x04\x20\ + \n\x0c\n\x05\x04\x02\x02\x04\x06\x12\x03\x11\x04\x10\n\x0c\n\x05\x04\x02\ + \x02\x04\x01\x12\x03\x11\x11\x1b\n\x0c\n\x05\x04\x02\x02\x04\x03\x12\x03\ + \x11\x1e\x1f\n\x0b\n\x04\x04\x02\x02\x05\x12\x03\x12\x04\x16\n\x0c\n\x05\ + \x04\x02\x02\x05\x05\x12\x03\x12\x04\t\n\x0c\n\x05\x04\x02\x02\x05\x01\ + \x12\x03\x12\n\x11\n\x0c\n\x05\x04\x02\x02\x05\x03\x12\x03\x12\x14\x15\n\ + \n\n\x02\x04\x03\x12\x04\x14\0\x16\x01\n\n\n\x03\x04\x03\x01\x12\x03\x14\ + \x08\x13\n\x0b\n\x04\x04\x03\x02\0\x12\x03\x15\x04\x1b\n\x0c\n\x05\x04\ + \x03\x02\0\x04\x12\x03\x15\x04\x0c\n\x0c\n\x05\x04\x03\x02\0\x06\x12\x03\ + \x15\r\x10\n\x0c\n\x05\x04\x03\x02\0\x01\x12\x03\x15\x11\x16\n\x0c\n\x05\ + \x04\x03\x02\0\x03\x12\x03\x15\x19\x1ab\x06proto3\ "; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; diff --git a/rust-lib/flowy-workspace/src/protobuf/model/app_query.rs b/rust-lib/flowy-workspace/src/protobuf/model/app_query.rs index 7d0451dc1d..c6d18239b7 100644 --- a/rust-lib/flowy-workspace/src/protobuf/model/app_query.rs +++ b/rust-lib/flowy-workspace/src/protobuf/model/app_query.rs @@ -27,7 +27,7 @@ pub struct QueryAppRequest { // message fields pub app_id: ::std::string::String, - pub read_views: bool, + pub read_belongings: bool, pub is_trash: bool, // special fields pub unknown_fields: ::protobuf::UnknownFields, @@ -71,19 +71,19 @@ impl QueryAppRequest { ::std::mem::replace(&mut self.app_id, ::std::string::String::new()) } - // bool read_views = 2; + // bool read_belongings = 2; - pub fn get_read_views(&self) -> bool { - self.read_views + pub fn get_read_belongings(&self) -> bool { + self.read_belongings } - pub fn clear_read_views(&mut self) { - self.read_views = false; + pub fn clear_read_belongings(&mut self) { + self.read_belongings = false; } // Param is passed by value, moved - pub fn set_read_views(&mut self, v: bool) { - self.read_views = v; + pub fn set_read_belongings(&mut self, v: bool) { + self.read_belongings = v; } // bool is_trash = 3; @@ -119,7 +119,7 @@ impl ::protobuf::Message for QueryAppRequest { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } let tmp = is.read_bool()?; - self.read_views = tmp; + self.read_belongings = tmp; }, 3 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { @@ -143,7 +143,7 @@ impl ::protobuf::Message for QueryAppRequest { if !self.app_id.is_empty() { my_size += ::protobuf::rt::string_size(1, &self.app_id); } - if self.read_views != false { + if self.read_belongings != false { my_size += 2; } if self.is_trash != false { @@ -158,8 +158,8 @@ impl ::protobuf::Message for QueryAppRequest { if !self.app_id.is_empty() { os.write_string(1, &self.app_id)?; } - if self.read_views != false { - os.write_bool(2, self.read_views)?; + if self.read_belongings != false { + os.write_bool(2, self.read_belongings)?; } if self.is_trash != false { os.write_bool(3, self.is_trash)?; @@ -208,9 +208,9 @@ impl ::protobuf::Message for QueryAppRequest { |m: &mut QueryAppRequest| { &mut m.app_id }, )); fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>( - "read_views", - |m: &QueryAppRequest| { &m.read_views }, - |m: &mut QueryAppRequest| { &mut m.read_views }, + "read_belongings", + |m: &QueryAppRequest| { &m.read_belongings }, + |m: &mut QueryAppRequest| { &mut m.read_belongings }, )); fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>( "is_trash", @@ -234,7 +234,7 @@ impl ::protobuf::Message for QueryAppRequest { impl ::protobuf::Clear for QueryAppRequest { fn clear(&mut self) { self.app_id.clear(); - self.read_views = false; + self.read_belongings = false; self.is_trash = false; self.unknown_fields.clear(); } @@ -253,20 +253,20 @@ impl ::protobuf::reflect::ProtobufValue for QueryAppRequest { } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x0fapp_query.proto\"b\n\x0fQueryAppRequest\x12\x15\n\x06app_id\x18\ - \x01\x20\x01(\tR\x05appId\x12\x1d\n\nread_views\x18\x02\x20\x01(\x08R\tr\ - eadViews\x12\x19\n\x08is_trash\x18\x03\x20\x01(\x08R\x07isTrashJ\xcf\x01\ - \n\x06\x12\x04\0\0\x06\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\ - \0\x12\x04\x02\0\x06\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\x17\n\x0b\n\ - \x04\x04\0\x02\0\x12\x03\x03\x04\x16\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\ - \x03\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x0b\x11\n\x0c\n\x05\ - \x04\0\x02\0\x03\x12\x03\x03\x14\x15\n\x0b\n\x04\x04\0\x02\x01\x12\x03\ - \x04\x04\x18\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\x04\x08\n\x0c\n\ - \x05\x04\0\x02\x01\x01\x12\x03\x04\t\x13\n\x0c\n\x05\x04\0\x02\x01\x03\ - \x12\x03\x04\x16\x17\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x05\x04\x16\n\x0c\ - \n\x05\x04\0\x02\x02\x05\x12\x03\x05\x04\x08\n\x0c\n\x05\x04\0\x02\x02\ - \x01\x12\x03\x05\t\x11\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x05\x14\x15\ - b\x06proto3\ + \n\x0fapp_query.proto\"l\n\x0fQueryAppRequest\x12\x15\n\x06app_id\x18\ + \x01\x20\x01(\tR\x05appId\x12'\n\x0fread_belongings\x18\x02\x20\x01(\x08\ + R\x0ereadBelongings\x12\x19\n\x08is_trash\x18\x03\x20\x01(\x08R\x07isTra\ + shJ\xcf\x01\n\x06\x12\x04\0\0\x06\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\ + \n\n\x02\x04\0\x12\x04\x02\0\x06\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\ + \x17\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x16\n\x0c\n\x05\x04\0\x02\0\ + \x05\x12\x03\x03\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x0b\x11\n\ + \x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x14\x15\n\x0b\n\x04\x04\0\x02\x01\ + \x12\x03\x04\x04\x1d\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\x04\x08\n\ + \x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\t\x18\n\x0c\n\x05\x04\0\x02\x01\ + \x03\x12\x03\x04\x1b\x1c\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x05\x04\x16\n\ + \x0c\n\x05\x04\0\x02\x02\x05\x12\x03\x05\x04\x08\n\x0c\n\x05\x04\0\x02\ + \x02\x01\x12\x03\x05\t\x11\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x05\x14\ + \x15b\x06proto3\ "; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; diff --git a/rust-lib/flowy-workspace/src/protobuf/model/observable.rs b/rust-lib/flowy-workspace/src/protobuf/model/observable.rs index 946760d6a1..09e7d2a3f8 100644 --- a/rust-lib/flowy-workspace/src/protobuf/model/observable.rs +++ b/rust-lib/flowy-workspace/src/protobuf/model/observable.rs @@ -26,11 +26,15 @@ #[derive(Clone,PartialEq,Eq,Debug,Hash)] pub enum WorkspaceObservable { Unknown = 0, - WorkspaceUpdateDesc = 10, - WorkspaceAddApp = 11, - AppUpdateDesc = 20, - AppAddView = 21, - ViewUpdateDesc = 30, + UserCreateWorkspace = 10, + UserDeleteWorkspace = 11, + WorkspaceUpdated = 12, + WorkspaceCreateApp = 13, + WorkspaceDeleteApp = 14, + AppUpdated = 21, + AppCreateView = 23, + AppDeleteView = 24, + ViewUpdated = 31, } impl ::protobuf::ProtobufEnum for WorkspaceObservable { @@ -41,11 +45,15 @@ impl ::protobuf::ProtobufEnum for WorkspaceObservable { fn from_i32(value: i32) -> ::std::option::Option { match value { 0 => ::std::option::Option::Some(WorkspaceObservable::Unknown), - 10 => ::std::option::Option::Some(WorkspaceObservable::WorkspaceUpdateDesc), - 11 => ::std::option::Option::Some(WorkspaceObservable::WorkspaceAddApp), - 20 => ::std::option::Option::Some(WorkspaceObservable::AppUpdateDesc), - 21 => ::std::option::Option::Some(WorkspaceObservable::AppAddView), - 30 => ::std::option::Option::Some(WorkspaceObservable::ViewUpdateDesc), + 10 => ::std::option::Option::Some(WorkspaceObservable::UserCreateWorkspace), + 11 => ::std::option::Option::Some(WorkspaceObservable::UserDeleteWorkspace), + 12 => ::std::option::Option::Some(WorkspaceObservable::WorkspaceUpdated), + 13 => ::std::option::Option::Some(WorkspaceObservable::WorkspaceCreateApp), + 14 => ::std::option::Option::Some(WorkspaceObservable::WorkspaceDeleteApp), + 21 => ::std::option::Option::Some(WorkspaceObservable::AppUpdated), + 23 => ::std::option::Option::Some(WorkspaceObservable::AppCreateView), + 24 => ::std::option::Option::Some(WorkspaceObservable::AppDeleteView), + 31 => ::std::option::Option::Some(WorkspaceObservable::ViewUpdated), _ => ::std::option::Option::None } } @@ -53,11 +61,15 @@ impl ::protobuf::ProtobufEnum for WorkspaceObservable { fn values() -> &'static [Self] { static values: &'static [WorkspaceObservable] = &[ WorkspaceObservable::Unknown, - WorkspaceObservable::WorkspaceUpdateDesc, - WorkspaceObservable::WorkspaceAddApp, - WorkspaceObservable::AppUpdateDesc, - WorkspaceObservable::AppAddView, - WorkspaceObservable::ViewUpdateDesc, + WorkspaceObservable::UserCreateWorkspace, + WorkspaceObservable::UserDeleteWorkspace, + WorkspaceObservable::WorkspaceUpdated, + WorkspaceObservable::WorkspaceCreateApp, + WorkspaceObservable::WorkspaceDeleteApp, + WorkspaceObservable::AppUpdated, + WorkspaceObservable::AppCreateView, + WorkspaceObservable::AppDeleteView, + WorkspaceObservable::ViewUpdated, ]; values } @@ -86,25 +98,35 @@ impl ::protobuf::reflect::ProtobufValue for WorkspaceObservable { } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x10observable.proto*\x87\x01\n\x13WorkspaceObservable\x12\x0b\n\x07Un\ - known\x10\0\x12\x17\n\x13WorkspaceUpdateDesc\x10\n\x12\x13\n\x0fWorkspac\ - eAddApp\x10\x0b\x12\x11\n\rAppUpdateDesc\x10\x14\x12\x0e\n\nAppAddView\ - \x10\x15\x12\x12\n\x0eViewUpdateDesc\x10\x1eJ\xa0\x02\n\x06\x12\x04\0\0\ - \t\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x05\0\x12\x04\x02\0\t\ - \x01\n\n\n\x03\x05\0\x01\x12\x03\x02\x05\x18\n\x0b\n\x04\x05\0\x02\0\x12\ - \x03\x03\x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x03\x04\x0b\n\x0c\n\ - \x05\x05\0\x02\0\x02\x12\x03\x03\x0e\x0f\n\x0b\n\x04\x05\0\x02\x01\x12\ - \x03\x04\x04\x1d\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x04\x04\x17\n\x0c\ - \n\x05\x05\0\x02\x01\x02\x12\x03\x04\x1a\x1c\n\x0b\n\x04\x05\0\x02\x02\ - \x12\x03\x05\x04\x19\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\x05\x04\x13\n\ - \x0c\n\x05\x05\0\x02\x02\x02\x12\x03\x05\x16\x18\n\x0b\n\x04\x05\0\x02\ - \x03\x12\x03\x06\x04\x17\n\x0c\n\x05\x05\0\x02\x03\x01\x12\x03\x06\x04\ - \x11\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\x06\x14\x16\n\x0b\n\x04\x05\0\ - \x02\x04\x12\x03\x07\x04\x14\n\x0c\n\x05\x05\0\x02\x04\x01\x12\x03\x07\ - \x04\x0e\n\x0c\n\x05\x05\0\x02\x04\x02\x12\x03\x07\x11\x13\n\x0b\n\x04\ - \x05\0\x02\x05\x12\x03\x08\x04\x18\n\x0c\n\x05\x05\0\x02\x05\x01\x12\x03\ - \x08\x04\x12\n\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\x08\x15\x17b\x06proto\ - 3\ + \n\x10observable.proto*\xe1\x01\n\x13WorkspaceObservable\x12\x0b\n\x07Un\ + known\x10\0\x12\x17\n\x13UserCreateWorkspace\x10\n\x12\x17\n\x13UserDele\ + teWorkspace\x10\x0b\x12\x14\n\x10WorkspaceUpdated\x10\x0c\x12\x16\n\x12W\ + orkspaceCreateApp\x10\r\x12\x16\n\x12WorkspaceDeleteApp\x10\x0e\x12\x0e\ + \n\nAppUpdated\x10\x15\x12\x11\n\rAppCreateView\x10\x17\x12\x11\n\rAppDe\ + leteView\x10\x18\x12\x0f\n\x0bViewUpdated\x10\x1fJ\xc4\x03\n\x06\x12\x04\ + \0\0\r\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x05\0\x12\x04\x02\0\ + \r\x01\n\n\n\x03\x05\0\x01\x12\x03\x02\x05\x18\n\x0b\n\x04\x05\0\x02\0\ + \x12\x03\x03\x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x03\x04\x0b\n\ + \x0c\n\x05\x05\0\x02\0\x02\x12\x03\x03\x0e\x0f\n\x0b\n\x04\x05\0\x02\x01\ + \x12\x03\x04\x04\x1d\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x04\x04\x17\n\ + \x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x04\x1a\x1c\n\x0b\n\x04\x05\0\x02\ + \x02\x12\x03\x05\x04\x1d\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\x05\x04\ + \x17\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\x05\x1a\x1c\n\x0b\n\x04\x05\0\ + \x02\x03\x12\x03\x06\x04\x1a\n\x0c\n\x05\x05\0\x02\x03\x01\x12\x03\x06\ + \x04\x14\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\x06\x17\x19\n\x0b\n\x04\ + \x05\0\x02\x04\x12\x03\x07\x04\x1c\n\x0c\n\x05\x05\0\x02\x04\x01\x12\x03\ + \x07\x04\x16\n\x0c\n\x05\x05\0\x02\x04\x02\x12\x03\x07\x19\x1b\n\x0b\n\ + \x04\x05\0\x02\x05\x12\x03\x08\x04\x1c\n\x0c\n\x05\x05\0\x02\x05\x01\x12\ + \x03\x08\x04\x16\n\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\x08\x19\x1b\n\x0b\ + \n\x04\x05\0\x02\x06\x12\x03\t\x04\x14\n\x0c\n\x05\x05\0\x02\x06\x01\x12\ + \x03\t\x04\x0e\n\x0c\n\x05\x05\0\x02\x06\x02\x12\x03\t\x11\x13\n\x0b\n\ + \x04\x05\0\x02\x07\x12\x03\n\x04\x17\n\x0c\n\x05\x05\0\x02\x07\x01\x12\ + \x03\n\x04\x11\n\x0c\n\x05\x05\0\x02\x07\x02\x12\x03\n\x14\x16\n\x0b\n\ + \x04\x05\0\x02\x08\x12\x03\x0b\x04\x17\n\x0c\n\x05\x05\0\x02\x08\x01\x12\ + \x03\x0b\x04\x11\n\x0c\n\x05\x05\0\x02\x08\x02\x12\x03\x0b\x14\x16\n\x0b\ + \n\x04\x05\0\x02\t\x12\x03\x0c\x04\x15\n\x0c\n\x05\x05\0\x02\t\x01\x12\ + \x03\x0c\x04\x0f\n\x0c\n\x05\x05\0\x02\t\x02\x12\x03\x0c\x12\x14b\x06pro\ + to3\ "; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; diff --git a/rust-lib/flowy-workspace/src/protobuf/model/view_create.rs b/rust-lib/flowy-workspace/src/protobuf/model/view_create.rs index 03b38961b8..cb119a0934 100644 --- a/rust-lib/flowy-workspace/src/protobuf/model/view_create.rs +++ b/rust-lib/flowy-workspace/src/protobuf/model/view_create.rs @@ -388,6 +388,7 @@ pub struct View { pub desc: ::std::string::String, pub view_type: ViewType, pub version: i64, + pub belongings: ::protobuf::SingularPtrField, // special fields pub unknown_fields: ::protobuf::UnknownFields, pub cached_size: ::protobuf::CachedSize, @@ -537,10 +538,48 @@ impl View { pub fn set_version(&mut self, v: i64) { self.version = v; } + + // .RepeatedView belongings = 7; + + + pub fn get_belongings(&self) -> &RepeatedView { + self.belongings.as_ref().unwrap_or_else(|| ::default_instance()) + } + pub fn clear_belongings(&mut self) { + self.belongings.clear(); + } + + pub fn has_belongings(&self) -> bool { + self.belongings.is_some() + } + + // Param is passed by value, moved + pub fn set_belongings(&mut self, v: RepeatedView) { + self.belongings = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_belongings(&mut self) -> &mut RepeatedView { + if self.belongings.is_none() { + self.belongings.set_default(); + } + self.belongings.as_mut().unwrap() + } + + // Take field + pub fn take_belongings(&mut self) -> RepeatedView { + self.belongings.take().unwrap_or_else(|| RepeatedView::new()) + } } impl ::protobuf::Message for View { fn is_initialized(&self) -> bool { + for v in &self.belongings { + if !v.is_initialized() { + return false; + } + }; true } @@ -570,6 +609,9 @@ impl ::protobuf::Message for View { let tmp = is.read_int64()?; self.version = tmp; }, + 7 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.belongings)?; + }, _ => { ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; }, @@ -600,6 +642,10 @@ impl ::protobuf::Message for View { if self.version != 0 { my_size += ::protobuf::rt::value_size(6, self.version, ::protobuf::wire_format::WireTypeVarint); } + if let Some(ref v) = self.belongings.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); self.cached_size.set(my_size); my_size @@ -624,6 +670,11 @@ impl ::protobuf::Message for View { if self.version != 0 { os.write_int64(6, self.version)?; } + if let Some(ref v) = self.belongings.as_ref() { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) } @@ -692,6 +743,11 @@ impl ::protobuf::Message for View { |m: &View| { &m.version }, |m: &mut View| { &mut m.version }, )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "belongings", + |m: &View| { &m.belongings }, + |m: &mut View| { &mut m.belongings }, + )); ::protobuf::reflect::MessageDescriptor::new_pb_name::( "View", fields, @@ -714,6 +770,7 @@ impl ::protobuf::Clear for View { self.desc.clear(); self.view_type = ViewType::Blank; self.version = 0; + self.belongings.clear(); self.unknown_fields.clear(); } } @@ -951,14 +1008,15 @@ static file_descriptor_proto_data: &'static [u8] = b"\ long_to_id\x18\x01\x20\x01(\tR\nbelongToId\x12\x12\n\x04name\x18\x02\x20\ \x01(\tR\x04name\x12\x12\n\x04desc\x18\x03\x20\x01(\tR\x04desc\x12\x1e\n\ \tthumbnail\x18\x04\x20\x01(\tH\0R\tthumbnail\x12&\n\tview_type\x18\x05\ - \x20\x01(\x0e2\t.ViewTypeR\x08viewTypeB\x12\n\x10one_of_thumbnail\"\xa2\ + \x20\x01(\x0e2\t.ViewTypeR\x08viewTypeB\x12\n\x10one_of_thumbnail\"\xd1\ \x01\n\x04View\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x20\n\x0cbe\ long_to_id\x18\x02\x20\x01(\tR\nbelongToId\x12\x12\n\x04name\x18\x03\x20\ \x01(\tR\x04name\x12\x12\n\x04desc\x18\x04\x20\x01(\tR\x04desc\x12&\n\tv\ iew_type\x18\x05\x20\x01(\x0e2\t.ViewTypeR\x08viewType\x12\x18\n\x07vers\ - ion\x18\x06\x20\x01(\x03R\x07version\"+\n\x0cRepeatedView\x12\x1b\n\x05i\ - tems\x18\x01\x20\x03(\x0b2\x05.ViewR\x05items*\x1e\n\x08ViewType\x12\t\n\ - \x05Blank\x10\0\x12\x07\n\x03Doc\x10\x01J\x81\x07\n\x06\x12\x04\0\0\x17\ + ion\x18\x06\x20\x01(\x03R\x07version\x12-\n\nbelongings\x18\x07\x20\x01(\ + \x0b2\r.RepeatedViewR\nbelongings\"+\n\x0cRepeatedView\x12\x1b\n\x05item\ + s\x18\x01\x20\x03(\x0b2\x05.ViewR\x05items*\x1e\n\x08ViewType\x12\t\n\ + \x05Blank\x10\0\x12\x07\n\x03Doc\x10\x01J\xb8\x07\n\x06\x12\x04\0\0\x18\ \x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x08\ \x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\x19\n\x0b\n\x04\x04\0\x02\0\x12\ \x03\x03\x04\x1c\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x03\x04\n\n\x0c\n\ @@ -975,7 +1033,7 @@ static file_descriptor_proto_data: &'static [u8] = b"\ \x04\0\x02\x03\x03\x12\x03\x0601\n\x0b\n\x04\x04\0\x02\x04\x12\x03\x07\ \x04\x1b\n\x0c\n\x05\x04\0\x02\x04\x06\x12\x03\x07\x04\x0c\n\x0c\n\x05\ \x04\0\x02\x04\x01\x12\x03\x07\r\x16\n\x0c\n\x05\x04\0\x02\x04\x03\x12\ - \x03\x07\x19\x1a\n\n\n\x02\x04\x01\x12\x04\t\0\x10\x01\n\n\n\x03\x04\x01\ + \x03\x07\x19\x1a\n\n\n\x02\x04\x01\x12\x04\t\0\x11\x01\n\n\n\x03\x04\x01\ \x01\x12\x03\t\x08\x0c\n\x0b\n\x04\x04\x01\x02\0\x12\x03\n\x04\x12\n\x0c\ \n\x05\x04\x01\x02\0\x05\x12\x03\n\x04\n\n\x0c\n\x05\x04\x01\x02\0\x01\ \x12\x03\n\x0b\r\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\n\x10\x11\n\x0b\n\ @@ -993,16 +1051,19 @@ static file_descriptor_proto_data: &'static [u8] = b"\ \x0e\x19\x1a\n\x0b\n\x04\x04\x01\x02\x05\x12\x03\x0f\x04\x16\n\x0c\n\x05\ \x04\x01\x02\x05\x05\x12\x03\x0f\x04\t\n\x0c\n\x05\x04\x01\x02\x05\x01\ \x12\x03\x0f\n\x11\n\x0c\n\x05\x04\x01\x02\x05\x03\x12\x03\x0f\x14\x15\n\ - \n\n\x02\x04\x02\x12\x04\x11\0\x13\x01\n\n\n\x03\x04\x02\x01\x12\x03\x11\ - \x08\x14\n\x0b\n\x04\x04\x02\x02\0\x12\x03\x12\x04\x1c\n\x0c\n\x05\x04\ - \x02\x02\0\x04\x12\x03\x12\x04\x0c\n\x0c\n\x05\x04\x02\x02\0\x06\x12\x03\ - \x12\r\x11\n\x0c\n\x05\x04\x02\x02\0\x01\x12\x03\x12\x12\x17\n\x0c\n\x05\ - \x04\x02\x02\0\x03\x12\x03\x12\x1a\x1b\n\n\n\x02\x05\0\x12\x04\x14\0\x17\ - \x01\n\n\n\x03\x05\0\x01\x12\x03\x14\x05\r\n\x0b\n\x04\x05\0\x02\0\x12\ - \x03\x15\x04\x0e\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x15\x04\t\n\x0c\n\ - \x05\x05\0\x02\0\x02\x12\x03\x15\x0c\r\n\x0b\n\x04\x05\0\x02\x01\x12\x03\ - \x16\x04\x0c\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x16\x04\x07\n\x0c\n\ - \x05\x05\0\x02\x01\x02\x12\x03\x16\n\x0bb\x06proto3\ + \x0b\n\x04\x04\x01\x02\x06\x12\x03\x10\x04\x20\n\x0c\n\x05\x04\x01\x02\ + \x06\x06\x12\x03\x10\x04\x10\n\x0c\n\x05\x04\x01\x02\x06\x01\x12\x03\x10\ + \x11\x1b\n\x0c\n\x05\x04\x01\x02\x06\x03\x12\x03\x10\x1e\x1f\n\n\n\x02\ + \x04\x02\x12\x04\x12\0\x14\x01\n\n\n\x03\x04\x02\x01\x12\x03\x12\x08\x14\ + \n\x0b\n\x04\x04\x02\x02\0\x12\x03\x13\x04\x1c\n\x0c\n\x05\x04\x02\x02\0\ + \x04\x12\x03\x13\x04\x0c\n\x0c\n\x05\x04\x02\x02\0\x06\x12\x03\x13\r\x11\ + \n\x0c\n\x05\x04\x02\x02\0\x01\x12\x03\x13\x12\x17\n\x0c\n\x05\x04\x02\ + \x02\0\x03\x12\x03\x13\x1a\x1b\n\n\n\x02\x05\0\x12\x04\x15\0\x18\x01\n\n\ + \n\x03\x05\0\x01\x12\x03\x15\x05\r\n\x0b\n\x04\x05\0\x02\0\x12\x03\x16\ + \x04\x0e\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x16\x04\t\n\x0c\n\x05\x05\0\ + \x02\0\x02\x12\x03\x16\x0c\r\n\x0b\n\x04\x05\0\x02\x01\x12\x03\x17\x04\ + \x0c\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x17\x04\x07\n\x0c\n\x05\x05\0\ + \x02\x01\x02\x12\x03\x17\n\x0bb\x06proto3\ "; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; diff --git a/rust-lib/flowy-workspace/src/protobuf/model/view_query.rs b/rust-lib/flowy-workspace/src/protobuf/model/view_query.rs index 9f33d6d200..9d53c8c27d 100644 --- a/rust-lib/flowy-workspace/src/protobuf/model/view_query.rs +++ b/rust-lib/flowy-workspace/src/protobuf/model/view_query.rs @@ -28,6 +28,7 @@ pub struct QueryViewRequest { // message fields pub view_id: ::std::string::String, pub is_trash: bool, + pub read_belongings: bool, // special fields pub unknown_fields: ::protobuf::UnknownFields, pub cached_size: ::protobuf::CachedSize, @@ -84,6 +85,21 @@ impl QueryViewRequest { pub fn set_is_trash(&mut self, v: bool) { self.is_trash = v; } + + // bool read_belongings = 3; + + + pub fn get_read_belongings(&self) -> bool { + self.read_belongings + } + pub fn clear_read_belongings(&mut self) { + self.read_belongings = false; + } + + // Param is passed by value, moved + pub fn set_read_belongings(&mut self, v: bool) { + self.read_belongings = v; + } } impl ::protobuf::Message for QueryViewRequest { @@ -105,6 +121,13 @@ impl ::protobuf::Message for QueryViewRequest { let tmp = is.read_bool()?; self.is_trash = tmp; }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.read_belongings = tmp; + }, _ => { ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; }, @@ -123,6 +146,9 @@ impl ::protobuf::Message for QueryViewRequest { if self.is_trash != false { my_size += 2; } + if self.read_belongings != false { + my_size += 2; + } my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); self.cached_size.set(my_size); my_size @@ -135,6 +161,9 @@ impl ::protobuf::Message for QueryViewRequest { if self.is_trash != false { os.write_bool(2, self.is_trash)?; } + if self.read_belongings != false { + os.write_bool(3, self.read_belongings)?; + } os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) } @@ -183,6 +212,11 @@ impl ::protobuf::Message for QueryViewRequest { |m: &QueryViewRequest| { &m.is_trash }, |m: &mut QueryViewRequest| { &mut m.is_trash }, )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "read_belongings", + |m: &QueryViewRequest| { &m.read_belongings }, + |m: &mut QueryViewRequest| { &mut m.read_belongings }, + )); ::protobuf::reflect::MessageDescriptor::new_pb_name::( "QueryViewRequest", fields, @@ -201,6 +235,7 @@ impl ::protobuf::Clear for QueryViewRequest { fn clear(&mut self) { self.view_id.clear(); self.is_trash = false; + self.read_belongings = false; self.unknown_fields.clear(); } } @@ -218,16 +253,20 @@ impl ::protobuf::reflect::ProtobufValue for QueryViewRequest { } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x10view_query.proto\"F\n\x10QueryViewRequest\x12\x17\n\x07view_id\x18\ + \n\x10view_query.proto\"o\n\x10QueryViewRequest\x12\x17\n\x07view_id\x18\ \x01\x20\x01(\tR\x06viewId\x12\x19\n\x08is_trash\x18\x02\x20\x01(\x08R\ - \x07isTrashJ\x98\x01\n\x06\x12\x04\0\0\x05\x01\n\x08\n\x01\x0c\x12\x03\0\ - \0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\ - \x02\x08\x18\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x17\n\x0c\n\x05\x04\ - \0\x02\0\x05\x12\x03\x03\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\ - \x0b\x12\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x15\x16\n\x0b\n\x04\x04\ - \0\x02\x01\x12\x03\x04\x04\x16\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\ + \x07isTrash\x12'\n\x0fread_belongings\x18\x03\x20\x01(\x08R\x0ereadBelon\ + gingsJ\xcf\x01\n\x06\x12\x04\0\0\x06\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\ + \n\n\n\x02\x04\0\x12\x04\x02\0\x06\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\ + \x08\x18\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x17\n\x0c\n\x05\x04\0\ + \x02\0\x05\x12\x03\x03\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x0b\ + \x12\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x15\x16\n\x0b\n\x04\x04\0\ + \x02\x01\x12\x03\x04\x04\x16\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\ \x04\x08\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\t\x11\n\x0c\n\x05\x04\ - \0\x02\x01\x03\x12\x03\x04\x14\x15b\x06proto3\ + \0\x02\x01\x03\x12\x03\x04\x14\x15\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x05\ + \x04\x1d\n\x0c\n\x05\x04\0\x02\x02\x05\x12\x03\x05\x04\x08\n\x0c\n\x05\ + \x04\0\x02\x02\x01\x12\x03\x05\t\x18\n\x0c\n\x05\x04\0\x02\x02\x03\x12\ + \x03\x05\x1b\x1cb\x06proto3\ "; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/app_create.proto b/rust-lib/flowy-workspace/src/protobuf/proto/app_create.proto index e94e5fa2f2..b6f8cd73c0 100644 --- a/rust-lib/flowy-workspace/src/protobuf/proto/app_create.proto +++ b/rust-lib/flowy-workspace/src/protobuf/proto/app_create.proto @@ -15,7 +15,7 @@ message App { string workspace_id = 2; string name = 3; string desc = 4; - RepeatedView views = 5; + RepeatedView belongings = 5; int64 version = 6; } message RepeatedApp { diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/app_query.proto b/rust-lib/flowy-workspace/src/protobuf/proto/app_query.proto index 3905035a80..95f73c5d24 100644 --- a/rust-lib/flowy-workspace/src/protobuf/proto/app_query.proto +++ b/rust-lib/flowy-workspace/src/protobuf/proto/app_query.proto @@ -2,6 +2,6 @@ syntax = "proto3"; message QueryAppRequest { string app_id = 1; - bool read_views = 2; + bool read_belongings = 2; bool is_trash = 3; } diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/observable.proto b/rust-lib/flowy-workspace/src/protobuf/proto/observable.proto index 1d6367dcf7..adca9e440b 100644 --- a/rust-lib/flowy-workspace/src/protobuf/proto/observable.proto +++ b/rust-lib/flowy-workspace/src/protobuf/proto/observable.proto @@ -2,9 +2,13 @@ syntax = "proto3"; enum WorkspaceObservable { Unknown = 0; - WorkspaceUpdateDesc = 10; - WorkspaceAddApp = 11; - AppUpdateDesc = 20; - AppAddView = 21; - ViewUpdateDesc = 30; + UserCreateWorkspace = 10; + UserDeleteWorkspace = 11; + WorkspaceUpdated = 12; + WorkspaceCreateApp = 13; + WorkspaceDeleteApp = 14; + AppUpdated = 21; + AppCreateView = 23; + AppDeleteView = 24; + ViewUpdated = 31; } diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/view_create.proto b/rust-lib/flowy-workspace/src/protobuf/proto/view_create.proto index b3d8d5a326..908e5ce99f 100644 --- a/rust-lib/flowy-workspace/src/protobuf/proto/view_create.proto +++ b/rust-lib/flowy-workspace/src/protobuf/proto/view_create.proto @@ -14,6 +14,7 @@ message View { string desc = 4; ViewType view_type = 5; int64 version = 6; + RepeatedView belongings = 7; } message RepeatedView { repeated View items = 1; diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/view_query.proto b/rust-lib/flowy-workspace/src/protobuf/proto/view_query.proto index 774edad465..c27e29bad6 100644 --- a/rust-lib/flowy-workspace/src/protobuf/proto/view_query.proto +++ b/rust-lib/flowy-workspace/src/protobuf/proto/view_query.proto @@ -3,4 +3,5 @@ syntax = "proto3"; message QueryViewRequest { string view_id = 1; bool is_trash = 2; + bool read_belongings = 3; } diff --git a/rust-lib/flowy-workspace/src/services/app_controller.rs b/rust-lib/flowy-workspace/src/services/app_controller.rs index bfbad2f281..00f8423a13 100644 --- a/rust-lib/flowy-workspace/src/services/app_controller.rs +++ b/rust-lib/flowy-workspace/src/services/app_controller.rs @@ -36,7 +36,8 @@ impl AppController { let app_table = AppTable::new(params); let app: App = app_table.clone().into(); let _ = self.sql.create_app(app_table)?; - send_observable(&app.workspace_id, WorkspaceObservable::WorkspaceAddApp); + + send_observable(&app.workspace_id, WorkspaceObservable::WorkspaceCreateApp); Ok(app) } @@ -46,7 +47,8 @@ impl AppController { } pub async fn delete_app(&self, app_id: &str) -> Result<(), WorkspaceError> { - let _ = self.sql.delete_app(app_id)?; + let app = self.sql.delete_app(app_id)?; + send_observable(&app.workspace_id, WorkspaceObservable::WorkspaceDeleteApp); Ok(()) } @@ -54,7 +56,7 @@ impl AppController { let changeset = AppTableChangeset::new(params); let app_id = changeset.id.clone(); let _ = self.sql.update_app(changeset)?; - send_observable(&app_id, WorkspaceObservable::AppUpdateDesc); + send_observable(&app_id, WorkspaceObservable::AppUpdated); Ok(()) } diff --git a/rust-lib/flowy-workspace/src/services/view_controller.rs b/rust-lib/flowy-workspace/src/services/view_controller.rs index e8e7c312c7..fb21f6abe6 100644 --- a/rust-lib/flowy-workspace/src/services/view_controller.rs +++ b/rust-lib/flowy-workspace/src/services/view_controller.rs @@ -22,7 +22,7 @@ impl ViewController { let view: View = view_table.clone().into(); let _ = self.sql.create_view(view_table)?; - send_observable(&view.belong_to_id, WorkspaceObservable::AppAddView); + send_observable(&view.belong_to_id, WorkspaceObservable::AppCreateView); Ok(view) } @@ -33,7 +33,8 @@ impl ViewController { } pub async fn delete_view(&self, view_id: &str) -> Result<(), WorkspaceError> { - let _ = self.sql.delete_view(view_id)?; + let view = self.sql.delete_view(view_id)?; + send_observable(&view.belong_to_id, WorkspaceObservable::AppDeleteView); Ok(()) } @@ -55,7 +56,7 @@ impl ViewController { let changeset = ViewTableChangeset::new(params); let view_id = changeset.id.clone(); let _ = self.sql.update_view(changeset)?; - send_observable(&view_id, WorkspaceObservable::ViewUpdateDesc); + send_observable(&view_id, WorkspaceObservable::ViewUpdated); Ok(()) } diff --git a/rust-lib/flowy-workspace/src/services/workspace_controller.rs b/rust-lib/flowy-workspace/src/services/workspace_controller.rs index 68c251ab49..858b8d63b1 100644 --- a/rust-lib/flowy-workspace/src/services/workspace_controller.rs +++ b/rust-lib/flowy-workspace/src/services/workspace_controller.rs @@ -35,9 +35,10 @@ impl WorkspaceController { ) -> Result { let user_id = self.user.user_id()?; let workspace_table = WorkspaceTable::new(params, &user_id); - let detail: Workspace = workspace_table.clone().into(); + let workspace: Workspace = workspace_table.clone().into(); let _ = self.sql.create_workspace(workspace_table)?; - Ok(detail) + send_observable(&user_id, WorkspaceObservable::UserCreateWorkspace); + Ok(workspace) } pub fn update_workspace(&self, params: UpdateWorkspaceParams) -> Result<(), WorkspaceError> { @@ -45,12 +46,15 @@ impl WorkspaceController { let workspace_id = changeset.id.clone(); let _ = self.sql.update_workspace(changeset)?; - send_observable(&workspace_id, WorkspaceObservable::WorkspaceUpdateDesc); + send_observable(&workspace_id, WorkspaceObservable::WorkspaceUpdated); Ok(()) } - pub fn delete_workspace(&self, _workspace_id: &str) -> Result<(), WorkspaceError> { - unimplemented!() + pub fn delete_workspace(&self, workspace_id: &str) -> Result<(), WorkspaceError> { + let user_id = self.user.user_id()?; + let _ = self.sql.delete_workspace(workspace_id)?; + send_observable(&user_id, WorkspaceObservable::UserDeleteWorkspace); + Ok(()) } pub async fn read_cur_workspace(&self) -> Result { diff --git a/rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rs b/rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rs index 19b0b6ecf2..035e5dd513 100644 --- a/rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rs +++ b/rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rs @@ -44,10 +44,14 @@ impl AppTableSql { Ok(app_table) } - pub(crate) fn delete_app(&self, app_id: &str) -> Result<(), WorkspaceError> { + pub(crate) fn delete_app(&self, app_id: &str) -> Result { let conn = self.database.db_connection()?; + // TODO: group into sql transaction + let app_table = dsl::app_table + .filter(app_table::id.eq(app_id)) + .first::(&*(self.database.db_connection()?))?; diesel_delete_table!(app_table, app_id, conn); - Ok(()) + Ok(app_table) } // pub(crate) fn read_views_belong_to_app( diff --git a/rust-lib/flowy-workspace/src/sql_tables/app/app_table.rs b/rust-lib/flowy-workspace/src/sql_tables/app/app_table.rs index 29fa36da36..c15f2e201a 100644 --- a/rust-lib/flowy-workspace/src/sql_tables/app/app_table.rs +++ b/rust-lib/flowy-workspace/src/sql_tables/app/app_table.rs @@ -108,7 +108,7 @@ impl std::convert::Into for AppTable { workspace_id: self.workspace_id, name: self.name, desc: self.desc, - views: RepeatedView::default(), + belongings: RepeatedView::default(), version: self.version, } } diff --git a/rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rs b/rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rs index 6b24ea7d18..34a699e70a 100644 --- a/rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rs +++ b/rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rs @@ -52,9 +52,15 @@ impl ViewTableSql { Ok(()) } - pub fn delete_view(&self, view_id: &str) -> Result<(), WorkspaceError> { + pub(crate) fn delete_view(&self, view_id: &str) -> Result { let conn = self.database.db_connection()?; + + // TODO: group into transaction + let view_table = dsl::view_table + .filter(view_table::id.eq(view_id)) + .first::(&*(self.database.db_connection()?))?; + diesel_delete_table!(view_table, view_id, conn); - Ok(()) + Ok(view_table) } } diff --git a/rust-lib/flowy-workspace/src/sql_tables/view/view_table.rs b/rust-lib/flowy-workspace/src/sql_tables/view/view_table.rs index aa6c4359f5..0de1194e83 100644 --- a/rust-lib/flowy-workspace/src/sql_tables/view/view_table.rs +++ b/rust-lib/flowy-workspace/src/sql_tables/view/view_table.rs @@ -1,5 +1,5 @@ use crate::{ - entities::view::{CreateViewParams, UpdateViewParams, View, ViewType}, + entities::view::{CreateViewParams, RepeatedView, UpdateViewParams, View, ViewType}, impl_sql_integer_expression, sql_tables::app::AppTable, }; @@ -54,6 +54,7 @@ impl std::convert::Into for ViewTable { name: self.name, desc: self.desc, view_type, + belongings: RepeatedView::default(), version: self.version, } } diff --git a/rust-lib/flowy-workspace/tests/event/app_test.rs b/rust-lib/flowy-workspace/tests/event/app_test.rs index 7bc99859ea..630555eb89 100644 --- a/rust-lib/flowy-workspace/tests/event/app_test.rs +++ b/rust-lib/flowy-workspace/tests/event/app_test.rs @@ -53,8 +53,8 @@ fn app_create_with_view_and_then_get_success() { let query = QueryAppRequest::new(&app.id).set_read_views(true); let view_from_db = read_app(query); - assert_eq!(view_from_db.views[0], view_a); - assert_eq!(view_from_db.views[1], view_b); + assert_eq!(view_from_db.belongings[0], view_a); + assert_eq!(view_from_db.belongings[1], view_b); } #[test]