-
-
Notifications
You must be signed in to change notification settings - Fork 214
refactor(gotrue): Remove unused _currentUser field and update currentUser getter logic. #1168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,9 +43,6 @@ class GoTrueClient { | |
/// Namespace for the GoTrue MFA API methods. | ||
late final GoTrueMFAApi mfa; | ||
|
||
/// The currently logged in user or null. | ||
User? _currentUser; | ||
|
||
/// The session object for the currently logged in user or null. | ||
Session? _currentSession; | ||
|
||
|
@@ -137,13 +134,8 @@ class GoTrueClient { | |
/// Getter for the headers | ||
Map<String, String> get headers => _headers; | ||
|
||
/// Returns the current logged in user, if any; | ||
/// | ||
/// Use [currentSession] to determine whether the user has an active session, | ||
/// because [currentUser] can be non-null without an active session, such as | ||
/// when the user signed up using email and password but has not confirmed | ||
/// their email address. | ||
User? get currentUser => _currentUser; | ||
/// Returns the current logged in user, asociated to [currentSession] if any; | ||
User? get currentUser => _currentSession?.user; | ||
|
||
/// Returns the current session, if any; | ||
Session? get currentSession => _currentSession; | ||
|
@@ -748,7 +740,6 @@ class GoTrueClient { | |
options: options); | ||
final userResponse = UserResponse.fromJson(response); | ||
|
||
_currentUser = userResponse.user; | ||
_currentSession = currentSession?.copyWith(user: userResponse.user); | ||
notifyAllSubscribers(AuthChangeEvent.userUpdated); | ||
|
||
|
@@ -970,7 +961,6 @@ class GoTrueClient { | |
} | ||
|
||
_currentSession = session; | ||
_currentUser = session.user; | ||
notifyAllSubscribers(AuthChangeEvent.initialSession); | ||
} | ||
|
||
|
@@ -997,7 +987,7 @@ class GoTrueClient { | |
} | ||
} else { | ||
final shouldEmitEvent = _currentSession == null || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if current session is null, then the second bang operator in the expression will never reach |
||
_currentSession?.user.id != session.user.id; | ||
_currentSession!.user.id != session.user.id; | ||
_saveSession(session); | ||
|
||
if (shouldEmitEvent) { | ||
|
@@ -1153,13 +1143,11 @@ class GoTrueClient { | |
_log.finest('Saving session: $session'); | ||
_log.fine('Saving session'); | ||
_currentSession = session; | ||
_currentUser = session.user; | ||
} | ||
|
||
void _removeSession() { | ||
_log.fine('Removing session'); | ||
_currentSession = null; | ||
_currentUser = null; | ||
} | ||
|
||
void _mayStartBroadcastChannel() { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.