File tree 5 files changed +13
-9
lines changed
5 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -239,7 +239,9 @@ - (FIRApp *) firebaseApp
239
239
240
240
// if (!self.configured) {
241
241
242
- [FIRApp configureWithOptions: finalOptions];
242
+ if ([FIRApp defaultApp ] == NULL ) {
243
+ [FIRApp configureWithOptions: finalOptions];
244
+ }
243
245
[Firestack initializeFirestack: self ];
244
246
callback (@[[NSNull null ], props]);
245
247
}
Original file line number Diff line number Diff line change 15
15
16
16
@interface FirestackAuth : RCTEventEmitter <RCTBridgeModule> {
17
17
FIRAuthStateDidChangeListenerHandle authListenerHandle;
18
+ Boolean listening;
18
19
}
19
20
20
21
@end
Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ @implementation FirestackAuth
130
130
131
131
RCT_EXPORT_METHOD (listenForAuth)
132
132
{
133
+ self->listening = true ;
133
134
self->authListenerHandle =
134
135
[[FIRAuth auth ] addAuthStateDidChangeListener: ^(FIRAuth *_Nonnull auth,
135
136
FIRUser *_Nullable user) {
@@ -174,15 +175,11 @@ @implementation FirestackAuth
174
175
{
175
176
if (self->authListenerHandle != nil ) {
176
177
[[FIRAuth auth ] removeAuthStateDidChangeListener: self ->authListenerHandle];
178
+ self->listening = false ;
177
179
callback (@[[NSNull null ]]);
178
180
}
179
181
}
180
182
181
- // Helper
182
- - (Boolean ) listeningForAuth {
183
- return (self->authListenerHandle != nil );
184
- }
185
-
186
183
RCT_EXPORT_METHOD (getCurrentUser:(RCTResponseSenderBlock)callback)
187
184
{
188
185
FIRUser *user = [FIRAuth auth ].currentUser ;
@@ -496,7 +493,7 @@ - (void) sendJSEvent:(NSString *)title
496
493
props : (NSDictionary *)props
497
494
{
498
495
@try {
499
- if ([ self listeningForAuth ] ) {
496
+ if (self-> listening ) {
500
497
[self sendEventWithName: title
501
498
body: props];
502
499
}
Original file line number Diff line number Diff line change @@ -240,7 +240,11 @@ @implementation FirestackDatabase
240
240
RCT_EXPORT_METHOD (enablePersistence:(BOOL ) enable
241
241
callback:(RCTResponseSenderBlock) callback)
242
242
{
243
- [FIRDatabase database ].persistenceEnabled = enable;
243
+
244
+ BOOL isEnabled = [FIRDatabase database ].persistenceEnabled ;
245
+ if ( isEnabled != enable) {
246
+ [FIRDatabase database ].persistenceEnabled = enable;
247
+ }
244
248
callback (@[[NSNull null ], @{
245
249
@" result" : @" success"
246
250
}]);
Original file line number Diff line number Diff line change @@ -367,11 +367,11 @@ export class Database extends Base {
367
367
}
368
368
369
369
setPersistence ( enable = true ) {
370
- this . persistenceEnabled = enable ;
371
370
let promise ;
372
371
if ( this . persistenceEnabled !== enable ) {
373
372
this . log . debug ( `${ enable ? 'Enabling' : 'Disabling' } persistence` ) ;
374
373
promise = this . whenReady ( promisify ( 'enablePersistence' , FirestackDatabase ) ( enable ) ) ;
374
+ this . persistenceEnabled = enable ;
375
375
} else {
376
376
promise = this . whenReady ( Promise . resolve ( { status : "Already enabled" } ) )
377
377
}
You can’t perform that action at this time.
0 commit comments