diff --git a/frontend/appflowy_flutter/lib/core/helpers/url_launcher.dart b/frontend/appflowy_flutter/lib/core/helpers/url_launcher.dart index c01d72a7fd..e8c9be51d5 100644 --- a/frontend/appflowy_flutter/lib/core/helpers/url_launcher.dart +++ b/frontend/appflowy_flutter/lib/core/helpers/url_launcher.dart @@ -27,8 +27,7 @@ Future afLaunchUrl( ); } on PlatformException catch (e) { Log.error('Failed to open uri: $e'); - } finally { - result = false; + return false; } // if the uri is not a valid url, try to launch it with http scheme diff --git a/frontend/appflowy_flutter/lib/startup/tasks/appflowy_cloud_task.dart b/frontend/appflowy_flutter/lib/startup/tasks/appflowy_cloud_task.dart index 7f174428bf..75c43f64fd 100644 --- a/frontend/appflowy_flutter/lib/startup/tasks/appflowy_cloud_task.dart +++ b/frontend/appflowy_flutter/lib/startup/tasks/appflowy_cloud_task.dart @@ -89,8 +89,10 @@ class AppFlowyCloudDeepLink { Log.error('onDeepLinkError: Unexpected empty deep link callback'); _completer?.complete(FlowyResult.failure(AuthError.emptyDeepLink)); _completer = null; + return; } - return _isAuthCallbackDeepLink(uri!).fold( + + return _isAuthCallbackDeepLink(uri).fold( (_) async { final deviceId = await getDeviceId(); final payload = OauthSignInPB( @@ -101,8 +103,7 @@ class AppFlowyCloudDeepLink { }, ); _stateNotifier?.value = DeepLinkResult(state: DeepLinkState.loading); - final result = - await UserEventOauthSignIn(payload).send().then((value) => value); + final result = await UserEventOauthSignIn(payload).send(); _stateNotifier?.value = DeepLinkResult( state: DeepLinkState.finish, diff --git a/frontend/appflowy_flutter/lib/user/application/auth/af_cloud_auth_service.dart b/frontend/appflowy_flutter/lib/user/application/auth/af_cloud_auth_service.dart index aabbd6e286..010ffac63e 100644 --- a/frontend/appflowy_flutter/lib/user/application/auth/af_cloud_auth_service.dart +++ b/frontend/appflowy_flutter/lib/user/application/auth/af_cloud_auth_service.dart @@ -72,8 +72,9 @@ class AppFlowyCloudAuthService implements AuthService { throw Exception('AppFlowyCloudDeepLink is not registered'); } } else { - completer - .complete(FlowyResult.failure(AuthError.signInWithOauthError)); + completer.complete( + FlowyResult.failure(AuthError.unableToGetDeepLink), + ); } return completer.future; diff --git a/frontend/appflowy_flutter/lib/user/application/auth/auth_error.dart b/frontend/appflowy_flutter/lib/user/application/auth/auth_error.dart index 2d9858c717..06ddd90238 100644 --- a/frontend/appflowy_flutter/lib/user/application/auth/auth_error.dart +++ b/frontend/appflowy_flutter/lib/user/application/auth/auth_error.dart @@ -29,4 +29,8 @@ class AuthError { static final deepLinkError = FlowyError() ..msg = 'DeepLink error' ..code = ErrorCode.Internal; + + static final unableToGetDeepLink = FlowyError() + ..msg = 'Unable to get the deep link' + ..code = ErrorCode.Internal; }