@@ -61,29 +61,30 @@ public String getName() {
6161
6262 @ ReactMethod
6363 public void listenForAuth () {
64- mAuthListener = new FirebaseAuth . AuthStateListener ( ) {
65-
66- @ Override
67- public void onAuthStateChanged (@ NonNull FirebaseAuth firebaseAuth ) {
68- WritableMap msgMap = Arguments .createMap ();
69- msgMap .putString ("eventName" , "listenForAuth" );
64+ if ( mAuthListener == null ) {
65+ mAuthListener = new FirebaseAuth . AuthStateListener () {
66+ @ Override
67+ public void onAuthStateChanged (@ NonNull FirebaseAuth firebaseAuth ) {
68+ WritableMap msgMap = Arguments .createMap ();
69+ msgMap .putString ("eventName" , "listenForAuth" );
7070
71- if (FirestackAuthModule .this .user != null ) {
72- WritableMap userMap = getUserMap ();
71+ if (FirestackAuthModule .this .user != null ) {
72+ WritableMap userMap = getUserMap ();
7373
74- msgMap .putBoolean ("authenticated" , true );
75- msgMap .putMap ("user" , userMap );
74+ msgMap .putBoolean ("authenticated" , true );
75+ msgMap .putMap ("user" , userMap );
7676
77- FirestackUtils .sendEvent (mReactContext , "listenForAuth" , msgMap );
78- } else {
79- msgMap .putBoolean ("authenticated" , false );
80- FirestackUtils .sendEvent (mReactContext , "listenForAuth" , msgMap );
77+ FirestackUtils .sendEvent (mReactContext , "listenForAuth" , msgMap );
78+ } else {
79+ msgMap .putBoolean ("authenticated" , false );
80+ FirestackUtils .sendEvent (mReactContext , "listenForAuth" , msgMap );
81+ }
8182 }
82- }
83- };
83+ };
8484
85- mAuth = FirebaseAuth .getInstance ();
86- mAuth .addAuthStateListener (mAuthListener );
85+ mAuth = FirebaseAuth .getInstance ();
86+ mAuth .addAuthStateListener (mAuthListener );
87+ }
8788 }
8889
8990 @ ReactMethod
0 commit comments