From e3d9d4c42a0f72c0a75d9f00b7e450e60c3c6364 Mon Sep 17 00:00:00 2001 From: appflowy Date: Sun, 20 Feb 2022 16:34:15 +0800 Subject: [PATCH] chore: rename some enum --- frontend/app_flowy/lib/startup/startup.dart | 20 +++++++++--------- .../app_flowy/lib/startup/tasks/init_sdk.dart | 21 ++++++++----------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/frontend/app_flowy/lib/startup/startup.dart b/frontend/app_flowy/lib/startup/startup.dart index 798af38c49..283a751c75 100644 --- a/frontend/app_flowy/lib/startup/startup.dart +++ b/frontend/app_flowy/lib/startup/startup.dart @@ -52,7 +52,7 @@ class FlowyRunner { Future initGetIt( GetIt getIt, - IntegrationEnv env, + IntegrationMode env, EntryPoint f, ) async { getIt.registerFactory(() => f); @@ -65,7 +65,7 @@ Future initGetIt( class LaunchContext { GetIt getIt; - IntegrationEnv env; + IntegrationMode env; LaunchContext(this.getIt, this.env); } @@ -83,7 +83,7 @@ abstract class LaunchTask { class AppLauncher { List tasks; - IntegrationEnv env; + IntegrationMode env; GetIt getIt; AppLauncher(this.env, this.getIt) : tasks = List.from([]); @@ -100,26 +100,26 @@ class AppLauncher { } } -enum IntegrationEnv { +enum IntegrationMode { develop, release, test, } -extension IntegrationEnvExt on IntegrationEnv { +extension IntegrationEnvExt on IntegrationMode { bool isTest() { - return this == IntegrationEnv.test; + return this == IntegrationMode.test; } } -IntegrationEnv integrationEnv() { +IntegrationMode integrationEnv() { if (Platform.environment.containsKey('FLUTTER_TEST')) { - return IntegrationEnv.test; + return IntegrationMode.test; } if (kReleaseMode) { - return IntegrationEnv.release; + return IntegrationMode.release; } - return IntegrationEnv.develop; + return IntegrationMode.develop; } diff --git a/frontend/app_flowy/lib/startup/tasks/init_sdk.dart b/frontend/app_flowy/lib/startup/tasks/init_sdk.dart index 730f0c9e7a..6621ec9c69 100644 --- a/frontend/app_flowy/lib/startup/tasks/init_sdk.dart +++ b/frontend/app_flowy/lib/startup/tasks/init_sdk.dart @@ -10,29 +10,26 @@ class InitRustSDKTask extends LaunchTask { @override Future initialize(LaunchContext context) async { switch (context.env) { - case IntegrationEnv.develop: - Directory directory = await getApplicationDocumentsDirectory(); - return Directory('${directory.path}/flowy_dev').create().then( + case IntegrationMode.release: + Directory documentsDir = await getApplicationDocumentsDirectory(); + return Directory('${documentsDir.path}/flowy').create().then( (Directory directory) async { await context.getIt().init(directory); }, ); - case IntegrationEnv.release: - Directory directory = await getApplicationDocumentsDirectory(); - return Directory('${directory.path}/flowy').create().then( + case IntegrationMode.develop: + Directory documentsDir = await getApplicationDocumentsDirectory(); + return Directory('${documentsDir.path}/flowy_dev').create().then( (Directory directory) async { await context.getIt().init(directory); }, ); - case IntegrationEnv.test: - await context.getIt().init(testWorkingDirectory()); + case IntegrationMode.test: + final directory = Directory("${Directory.current.path}/.sandbox"); + await context.getIt().init(directory); break; default: assert(false, 'Unsupported env'); } } - - Directory testWorkingDirectory() { - return Directory("${Directory.current.path}/.sandbox"); - } }