Skip to content

Commit c4f4bcf

Browse files
authored
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
1 parent 9500abb commit c4f4bcf

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

frontend/appflowy_flutter/lib/env/cloud_env.dart

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,23 @@ import 'package:dartz/dartz.dart';
2020
Future<void> setAuthenticatorType(AuthenticatorType ty) async {
2121
switch (ty) {
2222
case AuthenticatorType.local:
23-
getIt<KeyValueStorage>().set(KVKeys.kCloudType, 0.toString());
23+
await getIt<KeyValueStorage>().set(KVKeys.kCloudType, 0.toString());
2424
break;
2525
case AuthenticatorType.supabase:
26-
getIt<KeyValueStorage>().set(KVKeys.kCloudType, 1.toString());
26+
await getIt<KeyValueStorage>().set(KVKeys.kCloudType, 1.toString());
2727
break;
2828
case AuthenticatorType.appflowyCloud:
29-
getIt<KeyValueStorage>().set(KVKeys.kCloudType, 2.toString());
29+
await getIt<KeyValueStorage>().set(KVKeys.kCloudType, 2.toString());
30+
await setAppFlowyCloudUrl(const Some(kAppflowyCloudUrl));
3031
break;
3132
case AuthenticatorType.appflowyCloudSelfHost:
32-
getIt<KeyValueStorage>().set(KVKeys.kCloudType, 3.toString());
33+
await getIt<KeyValueStorage>().set(KVKeys.kCloudType, 3.toString());
3334
break;
3435
}
3536
}
3637

38+
const String kAppflowyCloudUrl = "https://beta.appflowy.cloud";
39+
3740
/// Retrieves the currently set cloud type.
3841
///
3942
/// This method fetches the cloud type setting from the key-value storage
@@ -47,20 +50,24 @@ Future<void> setAuthenticatorType(AuthenticatorType ty) async {
4750
///
4851
Future<AuthenticatorType> getAuthenticatorType() async {
4952
final value = await getIt<KeyValueStorage>().get(KVKeys.kCloudType);
50-
return value.fold(() => AuthenticatorType.local, (s) {
51-
switch (s) {
52-
case "0":
53-
return AuthenticatorType.local;
54-
case "1":
55-
return AuthenticatorType.supabase;
56-
case "2":
57-
return AuthenticatorType.appflowyCloud;
58-
case "3":
59-
return AuthenticatorType.appflowyCloudSelfHost;
60-
default:
61-
return AuthenticatorType.local;
62-
}
63-
});
53+
if (value.isNone() && integrationMode().isRelease) {
54+
await setAuthenticatorType(AuthenticatorType.appflowyCloud);
55+
return AuthenticatorType.appflowyCloud;
56+
}
57+
58+
switch (value.getOrElse(() => "0")) {
59+
case "0":
60+
return AuthenticatorType.local;
61+
case "1":
62+
return AuthenticatorType.supabase;
63+
case "2":
64+
return AuthenticatorType.appflowyCloud;
65+
case "3":
66+
return AuthenticatorType.appflowyCloudSelfHost;
67+
default:
68+
await setAuthenticatorType(AuthenticatorType.appflowyCloud);
69+
return AuthenticatorType.appflowyCloud;
70+
}
6471
}
6572

6673
/// Determines whether authentication is enabled.

frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/setting_appflowy_cloud.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class AppFlowyCloudViewSetting extends StatelessWidget {
5959
title: LocaleKeys.settings_menu_restartAppTip.tr(),
6060
confirm: () async {
6161
await setAppFlowyCloudUrl(
62-
const Some("https://beta.appflowy.cloud"),
62+
const Some(kAppflowyCloudUrl),
6363
);
6464

6565
await setAuthenticatorType(AuthenticatorType.appflowyCloud);

0 commit comments

Comments
 (0)