Skip to content

Commit

Permalink
fix: consolidate _initialDeeplinkIsHandled and shouldHandleInitialDee…
Browse files Browse the repository at this point in the history
…plink
  • Loading branch information
dshukertjr committed Jun 18, 2022
1 parent 05daff9 commit d07f55b
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions lib/src/supabase_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class SupabaseAuth with WidgetsBindingObserver {
/// {@macro supabase.localstorage.accessToken}
Future<String?> get accessToken => _localStorage.accessToken();

/// **ATTENTION**: `getInitialLink`/`getInitialUri` should be handled
/// ONLY ONCE in your app's lifetime, since it is not meant to change
/// throughout your app's life.
bool _initialDeeplinkIsHandled = false;
String? _authCallbackUrlHostname;

Expand Down Expand Up @@ -160,18 +163,6 @@ class SupabaseAuth with WidgetsBindingObserver {
}
}

/// **ATTENTION**: `getInitialLink`/`getInitialUri` should be handled
/// ONLY ONCE in your app's lifetime, since it is not meant to change
/// throughout your app's life.
bool get _shouldHandleInitialDeeplink {
if (_initialDeeplinkIsHandled) {
return false;
} else {
_initialDeeplinkIsHandled = true;
return true;
}
}

/// if _authCallbackUrlHost not init, we treat all deeplink as auth callback
bool _isAuthCallbackDeeplink(Uri uri) {
if (_authCallbackUrlHostname == null) {
Expand Down Expand Up @@ -223,7 +214,8 @@ class SupabaseAuth with WidgetsBindingObserver {
///
/// We handle all exceptions, since it is called from initState.
Future<void> _handleInitialUri() async {
if (!_shouldHandleInitialDeeplink) return;
if (_initialDeeplinkIsHandled) return;
_initialDeeplinkIsHandled = true;

try {
final uri = await getInitialUri();
Expand Down

0 comments on commit d07f55b

Please sign in to comment.