diff --git a/app_flowy/lib/startup/tasks/rust_sdk_init_task.dart b/app_flowy/lib/startup/tasks/rust_sdk_init_task.dart index 679882a157..ad911d7232 100644 --- a/app_flowy/lib/startup/tasks/rust_sdk_init_task.dart +++ b/app_flowy/lib/startup/tasks/rust_sdk_init_task.dart @@ -19,20 +19,22 @@ class RustSDKInitTask extends LaunchTask { Directory directory = await getApplicationDocumentsDirectory(); final documentPath = directory.path; - final flowySandbox = Directory('$documentPath/flowy'); - switch (context.env) { - case IntegrationEnv.dev: - // await context.getIt().init(Directory('./temp/flowy_dev')); - await context.getIt().init(flowySandbox); - break; - case IntegrationEnv.pro: - await context.getIt().init(flowySandbox); - break; - default: - assert(false, 'Unsupported env'); - } - return Future(() => {}); + return Directory('$documentPath/flowy') + .create() + .then((Directory directory) async { + switch (context.env) { + case IntegrationEnv.dev: + // await context.getIt().init(Directory('./temp/flowy_dev')); + await context.getIt().init(directory); + break; + case IntegrationEnv.pro: + await context.getIt().init(directory); + break; + default: + assert(false, 'Unsupported env'); + } + }); } } diff --git a/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart b/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart index 8769a2d3df..acd9c2b4b3 100644 --- a/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart +++ b/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart @@ -23,7 +23,7 @@ class AppRepository { ..appId = appId ..readViews = false; - return WorkspaceEventGetApp(request).send(); + return WorkspaceEventReadApp(request).send(); } Future> createView( @@ -42,7 +42,7 @@ class AppRepository { ..appId = appId ..readViews = true; - return WorkspaceEventGetApp(request).send().then((result) { + return WorkspaceEventReadApp(request).send().then((result) { return result.fold( (app) => left(app.views.items), (error) => right(error), diff --git a/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart b/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart index 774ed698bc..1181eebf04 100644 --- a/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart +++ b/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart @@ -20,7 +20,7 @@ class WorkspaceRepo { }); Future> createApp(String appName, String desc) { - return WorkspaceEventGetCurWorkspace().send().then((result) { + return WorkspaceEventReadCurWorkspace().send().then((result) { return result.fold( (workspace) { final request = CreateAppRequest.create() @@ -42,7 +42,7 @@ class WorkspaceRepo { ..workspaceId = user.workspace ..readApps = readApps; - return WorkspaceEventGetWorkspace(request).send().then((result) { + return WorkspaceEventReadWorkspace(request).send().then((result) { return result.fold( (workspace) => left(workspace), (error) => right(error), diff --git a/app_flowy/packages/flowy_sdk/lib/dispatch/code_gen.dart b/app_flowy/packages/flowy_sdk/lib/dispatch/code_gen.dart index f2cbf09e49..f6e70ae4b9 100644 --- a/app_flowy/packages/flowy_sdk/lib/dispatch/code_gen.dart +++ b/app_flowy/packages/flowy_sdk/lib/dispatch/code_gen.dart @@ -87,12 +87,12 @@ class WorkspaceEventCreateWorkspace { } } -class WorkspaceEventGetCurWorkspace { - WorkspaceEventGetCurWorkspace(); +class WorkspaceEventReadCurWorkspace { + WorkspaceEventReadCurWorkspace(); Future> send() { final request = FFIRequest.create() - ..event = WorkspaceEvent.GetCurWorkspace.toString(); + ..event = WorkspaceEvent.ReadCurWorkspace.toString(); return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold( (okBytes) => left(Workspace.fromBuffer(okBytes)), @@ -101,13 +101,13 @@ class WorkspaceEventGetCurWorkspace { } } -class WorkspaceEventGetWorkspace { +class WorkspaceEventReadWorkspace { QueryWorkspaceRequest request; - WorkspaceEventGetWorkspace(this.request); + WorkspaceEventReadWorkspace(this.request); Future> send() { final request = FFIRequest.create() - ..event = WorkspaceEvent.GetWorkspace.toString() + ..event = WorkspaceEvent.ReadWorkspace.toString() ..payload = requestToBytes(this.request); return Dispatch.asyncRequest(request) @@ -118,6 +118,23 @@ class WorkspaceEventGetWorkspace { } } +class WorkspaceEventDeleteWorkspace { + DeleteWorkspaceRequest request; + WorkspaceEventDeleteWorkspace(this.request); + + Future> send() { + final request = FFIRequest.create() + ..event = WorkspaceEvent.DeleteWorkspace.toString() + ..payload = requestToBytes(this.request); + + return Dispatch.asyncRequest(request) + .then((bytesResult) => bytesResult.fold( + (bytes) => left(unit), + (errBytes) => right(WorkspaceError.fromBuffer(errBytes)), + )); + } +} + class WorkspaceEventReadAllWorkspace { WorkspaceEventReadAllWorkspace(); @@ -149,13 +166,30 @@ class WorkspaceEventCreateApp { } } -class WorkspaceEventGetApp { +class WorkspaceEventDeleteApp { + DeleteAppRequest request; + WorkspaceEventDeleteApp(this.request); + + Future> send() { + final request = FFIRequest.create() + ..event = WorkspaceEvent.DeleteApp.toString() + ..payload = requestToBytes(this.request); + + return Dispatch.asyncRequest(request) + .then((bytesResult) => bytesResult.fold( + (bytes) => left(unit), + (errBytes) => right(WorkspaceError.fromBuffer(errBytes)), + )); + } +} + +class WorkspaceEventReadApp { QueryAppRequest request; - WorkspaceEventGetApp(this.request); + WorkspaceEventReadApp(this.request); Future> send() { final request = FFIRequest.create() - ..event = WorkspaceEvent.GetApp.toString() + ..event = WorkspaceEvent.ReadApp.toString() ..payload = requestToBytes(this.request); return Dispatch.asyncRequest(request) @@ -166,6 +200,23 @@ class WorkspaceEventGetApp { } } +class WorkspaceEventUpdateApp { + UpdateAppRequest request; + WorkspaceEventUpdateApp(this.request); + + Future> send() { + final request = FFIRequest.create() + ..event = WorkspaceEvent.UpdateApp.toString() + ..payload = requestToBytes(this.request); + + return Dispatch.asyncRequest(request) + .then((bytesResult) => bytesResult.fold( + (bytes) => left(unit), + (errBytes) => right(WorkspaceError.fromBuffer(errBytes)), + )); + } +} + class WorkspaceEventCreateView { CreateViewRequest request; WorkspaceEventCreateView(this.request); @@ -217,6 +268,23 @@ class WorkspaceEventUpdateView { } } +class WorkspaceEventDeleteView { + DeleteViewRequest request; + WorkspaceEventDeleteView(this.request); + + Future> send() { + final request = FFIRequest.create() + ..event = WorkspaceEvent.DeleteView.toString() + ..payload = requestToBytes(this.request); + + return Dispatch.asyncRequest(request) + .then((bytesResult) => bytesResult.fold( + (bytes) => left(unit), + (errBytes) => right(WorkspaceError.fromBuffer(errBytes)), + )); + } +} + class UserEventGetStatus { UserEventGetStatus();