feat: custom server url in application (#3996)

* chore:test

* chore: update ui

* feat: set appflowy cloud url

* chore: add self host docs

* fix: save user

* fix: sign out when authenticator not match

* fix: sign out when authenticator not match

* fix: db lock

* chore: remove unuse env file

* test: disable supabase cloud test

* test: disable supabase cloud test

* chore: fix save
This commit is contained in:
Nathan.fooo
2023-11-24 11:54:47 +08:00
committed by GitHub
parent e18e031710
commit 1fad713477
63 changed files with 1758 additions and 721 deletions

View File

@ -43,6 +43,10 @@ class DependencyResolver {
GetIt getIt,
IntegrationMode mode,
) async {
// getIt.registerFactory<KeyValueStorage>(() => RustKeyValue());
getIt.registerFactory<KeyValueStorage>(() => DartKeyValue());
await _resolveCloudDeps(getIt);
_resolveUserDeps(getIt, mode);
_resolveHomeDeps(getIt);
_resolveFolderDeps(getIt);
@ -52,12 +56,23 @@ class DependencyResolver {
}
}
Future<void> _resolveCloudDeps(GetIt getIt) async {
final cloudType = await getCloudType();
final appflowyCloudConfig = await getAppFlowyCloudConfig();
final supabaseCloudConfig = await getSupabaseCloudConfig();
getIt.registerFactory<AppFlowyCloudSharedEnv>(() {
return AppFlowyCloudSharedEnv(
cloudType: cloudType,
appflowyCloudConfig: appflowyCloudConfig,
supabaseConfig: supabaseCloudConfig,
);
});
}
void _resolveCommonService(
GetIt getIt,
IntegrationMode mode,
) async {
// getIt.registerFactory<KeyValueStorage>(() => RustKeyValue());
getIt.registerFactory<KeyValueStorage>(() => DartKeyValue());
getIt.registerFactory<FilePickerService>(() => FilePicker());
if (mode.isTest) {
getIt.registerFactory<ApplicationDataStorage>(
@ -115,7 +130,7 @@ void _resolveCommonService(
void _resolveUserDeps(GetIt getIt, IntegrationMode mode) {
switch (currentCloudType()) {
case CloudType.unknown:
case CloudType.local:
getIt.registerFactory<AuthService>(
() => BackendAuthService(
AuthTypePB.Local,

View File

@ -45,7 +45,7 @@ class FlowyRunner {
await getIt.reset();
// Specify the env
initGetIt(getIt, mode, f, config);
await initGetIt(getIt, mode, f, config);
final applicationDataDirectory =
await getIt<ApplicationDataStorage>().getPath().then(

View File

@ -50,7 +50,7 @@ class WindowSizeManager {
Future<Offset?> getPosition() async {
final position = await getIt<KeyValueStorage>().get(KVKeys.windowPosition);
return position.fold(
(l) => null,
() => null,
(r) {
final offset = json.decode(r);
return Offset(offset[dx], offset[dy]);

View File

@ -45,41 +45,15 @@ AppFlowyConfiguration _getAppFlowyConfiguration(
String originAppPath,
String deviceId,
) {
if (isCloudEnabled) {
final supabaseConfig = SupabaseConfiguration(
url: Env.supabaseUrl,
anon_key: Env.supabaseAnonKey,
);
final appflowyCloudConfig = AppFlowyCloudConfiguration(
base_url: Env.afCloudBaseUrl,
ws_base_url: Env.afCloudWSBaseUrl,
gotrue_url: Env.afCloudGoTrueUrl,
);
return AppFlowyConfiguration(
custom_app_path: customAppPath,
origin_app_path: originAppPath,
device_id: deviceId,
cloud_type: Env.cloudType,
supabase_config: supabaseConfig,
appflowy_cloud_config: appflowyCloudConfig,
);
} else {
// Use the default configuration if the cloud feature is disabled
final supabaseConfig = SupabaseConfiguration.defaultConfig();
final appflowyCloudConfig = AppFlowyCloudConfiguration.defaultConfig();
return AppFlowyConfiguration(
custom_app_path: customAppPath,
origin_app_path: originAppPath,
device_id: deviceId,
// 0 means the cloud type is local
cloud_type: 0,
supabase_config: supabaseConfig,
appflowy_cloud_config: appflowyCloudConfig,
);
}
final env = getIt<AppFlowyCloudSharedEnv>();
return AppFlowyConfiguration(
custom_app_path: customAppPath,
origin_app_path: originAppPath,
device_id: deviceId,
cloud_type: env.cloudType.value,
supabase_config: env.supabaseConfig,
appflowy_cloud_config: env.appflowyCloudConfig,
);
}
/// The default directory to store the user data. The directory can be

View File

@ -36,8 +36,8 @@ class InitSupabaseTask extends LaunchTask {
supabase?.dispose();
supabase = null;
final initializedSupabase = await Supabase.initialize(
url: Env.supabaseUrl,
anonKey: Env.supabaseAnonKey,
url: getIt<AppFlowyCloudSharedEnv>().supabaseConfig.url,
anonKey: getIt<AppFlowyCloudSharedEnv>().supabaseConfig.anon_key,
debug: kDebugMode,
localStorage: const SupabaseLocalStorage(),
);