feat: using appflowy cloud as the default cloud type (#4380)

* feat: using appflowy cloud as the default cloud type

* fix: test

* Update cloud_env.dart
This commit is contained in:
Nathan.fooo 2024-01-13 03:08:07 +08:00 committed by GitHub
parent 9500abb363
commit c4f4bcf457
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 19 deletions

View File

@ -20,20 +20,23 @@ import 'package:dartz/dartz.dart';
Future<void> setAuthenticatorType(AuthenticatorType ty) async {
switch (ty) {
case AuthenticatorType.local:
getIt<KeyValueStorage>().set(KVKeys.kCloudType, 0.toString());
await getIt<KeyValueStorage>().set(KVKeys.kCloudType, 0.toString());
break;
case AuthenticatorType.supabase:
getIt<KeyValueStorage>().set(KVKeys.kCloudType, 1.toString());
await getIt<KeyValueStorage>().set(KVKeys.kCloudType, 1.toString());
break;
case AuthenticatorType.appflowyCloud:
getIt<KeyValueStorage>().set(KVKeys.kCloudType, 2.toString());
await getIt<KeyValueStorage>().set(KVKeys.kCloudType, 2.toString());
await setAppFlowyCloudUrl(const Some(kAppflowyCloudUrl));
break;
case AuthenticatorType.appflowyCloudSelfHost:
getIt<KeyValueStorage>().set(KVKeys.kCloudType, 3.toString());
await getIt<KeyValueStorage>().set(KVKeys.kCloudType, 3.toString());
break;
}
}
const String kAppflowyCloudUrl = "https://beta.appflowy.cloud";
/// Retrieves the currently set cloud type.
///
/// This method fetches the cloud type setting from the key-value storage
@ -47,20 +50,24 @@ Future<void> setAuthenticatorType(AuthenticatorType ty) async {
///
Future<AuthenticatorType> getAuthenticatorType() async {
final value = await getIt<KeyValueStorage>().get(KVKeys.kCloudType);
return value.fold(() => AuthenticatorType.local, (s) {
switch (s) {
case "0":
return AuthenticatorType.local;
case "1":
return AuthenticatorType.supabase;
case "2":
return AuthenticatorType.appflowyCloud;
case "3":
return AuthenticatorType.appflowyCloudSelfHost;
default:
return AuthenticatorType.local;
}
});
if (value.isNone() && integrationMode().isRelease) {
await setAuthenticatorType(AuthenticatorType.appflowyCloud);
return AuthenticatorType.appflowyCloud;
}
switch (value.getOrElse(() => "0")) {
case "0":
return AuthenticatorType.local;
case "1":
return AuthenticatorType.supabase;
case "2":
return AuthenticatorType.appflowyCloud;
case "3":
return AuthenticatorType.appflowyCloudSelfHost;
default:
await setAuthenticatorType(AuthenticatorType.appflowyCloud);
return AuthenticatorType.appflowyCloud;
}
}
/// Determines whether authentication is enabled.

View File

@ -59,7 +59,7 @@ class AppFlowyCloudViewSetting extends StatelessWidget {
title: LocaleKeys.settings_menu_restartAppTip.tr(),
confirm: () async {
await setAppFlowyCloudUrl(
const Some("https://beta.appflowy.cloud"),
const Some(kAppflowyCloudUrl),
);
await setAuthenticatorType(AuthenticatorType.appflowyCloud);