@@ -20,20 +20,23 @@ import 'package:dartz/dartz.dart';
2020Future <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///
4851Future <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.
0 commit comments