Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class FirebaseAuthWeb extends FirebaseAuthPlatform {
/// Called by PluginRegistry to register this plugin for Flutter Web
static void registerWith(Registrar registrar) {
FirebaseCoreWeb.registerService('auth', () async {
await FirebaseAuthWeb.instance.delegate.onWaitInitState();
// await FirebaseAuthWeb.instance.delegate.onWaitInitState();
});
FirebaseAuthPlatform.instance = FirebaseAuthWeb.instance;
PhoneMultiFactorGeneratorPlatform.instance = PhoneMultiFactorGeneratorWeb();
Expand Down
34 changes: 17 additions & 17 deletions packages/firebase_auth/firebase_auth_web/lib/src/interop/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -362,27 +362,27 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {

auth_interop.AuthSettings get settings => jsObject.settings;

User? _initUser;
// User? _initUser;

/// On web we need to wait for the first onAuthStateChanged event to fire
/// in order to be sure that the currentUser is set.
/// To preserve behavior on web and mobile we store the initial user
/// in `_initUser` and add it manually to the `_changeController`.
Future<void> onWaitInitState() async {
final completer = Completer();
final nextWrapper = allowInterop((auth_interop.UserJsImpl? user) {
_initUser = User.getInstance(user);
completer.complete();
});
// /// On web we need to wait for the first onAuthStateChanged event to fire
// /// in order to be sure that the currentUser is set.
// /// To preserve behavior on web and mobile we store the initial user
// /// in `_initUser` and add it manually to the `_changeController`.
// Future<void> onWaitInitState() async {
// final completer = Completer();
// final nextWrapper = allowInterop((auth_interop.UserJsImpl? user) {
// _initUser = User.getInstance(user);
// completer.complete();
// });

final errorWrapper = allowInterop((e) => _changeController!.addError(e));
// final errorWrapper = allowInterop((e) => _changeController!.addError(e));

final unsubscribe = jsObject.onAuthStateChanged(nextWrapper, errorWrapper);
// final unsubscribe = jsObject.onAuthStateChanged(nextWrapper, errorWrapper);

await completer.future;
// await completer.future;

unsubscribe();
}
// unsubscribe();
// }

Func0? _onAuthUnsubscribe;
// TODO(rrousselGit): fix memory leak – the controller isn't closed even in onCancel
Expand Down Expand Up @@ -420,7 +420,7 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
sync: true,
);

_changeController!.add(_initUser);
// _changeController!.add(_initUser);
}
return _changeController!.stream;
}
Expand Down