create flowy directory if not exist

This commit is contained in:
appflowy 2021-07-29 17:46:20 +08:00
parent c8ba8284ef
commit e67683abc7
4 changed files with 96 additions and 26 deletions

View File

@ -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<FlowySDK>().init(Directory('./temp/flowy_dev'));
await context.getIt<FlowySDK>().init(flowySandbox);
break;
case IntegrationEnv.pro:
await context.getIt<FlowySDK>().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<FlowySDK>().init(Directory('./temp/flowy_dev'));
await context.getIt<FlowySDK>().init(directory);
break;
case IntegrationEnv.pro:
await context.getIt<FlowySDK>().init(directory);
break;
default:
assert(false, 'Unsupported env');
}
});
}
}

View File

@ -23,7 +23,7 @@ class AppRepository {
..appId = appId
..readViews = false;
return WorkspaceEventGetApp(request).send();
return WorkspaceEventReadApp(request).send();
}
Future<Either<View, WorkspaceError>> 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),

View File

@ -20,7 +20,7 @@ class WorkspaceRepo {
});
Future<Either<App, WorkspaceError>> 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),

View File

@ -87,12 +87,12 @@ class WorkspaceEventCreateWorkspace {
}
}
class WorkspaceEventGetCurWorkspace {
WorkspaceEventGetCurWorkspace();
class WorkspaceEventReadCurWorkspace {
WorkspaceEventReadCurWorkspace();
Future<Either<Workspace, WorkspaceError>> 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<Either<Workspace, WorkspaceError>> 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<Either<Unit, WorkspaceError>> 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<Either<Unit, WorkspaceError>> 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<Either<App, WorkspaceError>> 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<Either<Unit, WorkspaceError>> 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<Either<Unit, WorkspaceError>> 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();