2
0
mirror of synced 2025-01-11 14:44:12 +00:00

[ios] Temporary fix for #233

This commit is contained in:
Chris Bianca 2017-10-12 09:42:38 +01:00
parent 114e3b2b5b
commit e76ab93a72
4 changed files with 40 additions and 8 deletions

View File

@ -87,7 +87,11 @@ RCT_EXPORT_METHOD(transactionStart:(NSString *) appName
dispatch_barrier_async(_transactionQueue, ^{ dispatch_barrier_async(_transactionQueue, ^{
[_transactions setValue:transactionState forKey:transactionId]; [_transactions setValue:transactionState forKey:transactionId];
NSDictionary *updateMap = [self createTransactionUpdateMap:appName transactionId:transactionId updatesData:currentData]; NSDictionary *updateMap = [self createTransactionUpdateMap:appName transactionId:transactionId updatesData:currentData];
[self sendEventWithName:DATABASE_TRANSACTION_EVENT body:updateMap]; // TODO: Temporary fix for https://github.com/invertase/react-native-firebase/issues/233
// until a better solution comes around
if (self.bridge) {
[self sendEventWithName:DATABASE_TRANSACTION_EVENT body:updateMap];
}
}); });
// wait for the js event handler to call tryCommitTransaction // wait for the js event handler to call tryCommitTransaction
@ -114,7 +118,11 @@ RCT_EXPORT_METHOD(transactionStart:(NSString *) appName
andCompletionBlock: andCompletionBlock:
^(NSError *_Nullable databaseError, BOOL committed, FIRDataSnapshot *_Nullable snapshot) { ^(NSError *_Nullable databaseError, BOOL committed, FIRDataSnapshot *_Nullable snapshot) {
NSDictionary *resultMap = [self createTransactionResultMap:appName transactionId:transactionId error:databaseError committed:committed snapshot:snapshot]; NSDictionary *resultMap = [self createTransactionResultMap:appName transactionId:transactionId error:databaseError committed:committed snapshot:snapshot];
[self sendEventWithName:DATABASE_TRANSACTION_EVENT body:resultMap]; // TODO: Temporary fix for https://github.com/invertase/react-native-firebase/issues/233
// until a better solution comes around
if (self.bridge) {
[self sendEventWithName:DATABASE_TRANSACTION_EVENT body:resultMap];
}
} }
withLocalEvents: withLocalEvents:
applyLocally]; applyLocally];

View File

@ -71,7 +71,11 @@
[event setValue:eventType forKey:@"eventType"]; [event setValue:eventType forKey:@"eventType"];
[event setValue:registration forKey:@"registration"]; [event setValue:registration forKey:@"registration"];
[_emitter sendEventWithName:DATABASE_SYNC_EVENT body:event]; // TODO: Temporary fix for https://github.com/invertase/react-native-firebase/issues/233
// until a better solution comes around
if (_emitter.bridge) {
[_emitter sendEventWithName:DATABASE_SYNC_EVENT body:event];
}
} }
- (void)handleDatabaseError:(NSDictionary *) registration - (void)handleDatabaseError:(NSDictionary *) registration
@ -81,7 +85,11 @@
[event setValue:[RNFirebaseDatabase getJSError:error] forKey:@"error"]; [event setValue:[RNFirebaseDatabase getJSError:error] forKey:@"error"];
[event setValue:registration forKey:@"registration"]; [event setValue:registration forKey:@"registration"];
[_emitter sendEventWithName:DATABASE_SYNC_EVENT body:event]; // TODO: Temporary fix for https://github.com/invertase/react-native-firebase/issues/233
// until a better solution comes around
if (_emitter) {
[_emitter sendEventWithName:DATABASE_SYNC_EVENT body:event];
}
} }
+ (NSDictionary *)snapshotToDictionary:(FIRDataSnapshot *) dataSnapshot + (NSDictionary *)snapshotToDictionary:(FIRDataSnapshot *) dataSnapshot

View File

@ -151,7 +151,11 @@ queryListenOptions:(NSDictionary *) queryListenOptions {
[event setValue:listenerId forKey:@"listenerId"]; [event setValue:listenerId forKey:@"listenerId"];
[event setValue:[RNFirebaseFirestore getJSError:error] forKey:@"error"]; [event setValue:[RNFirebaseFirestore getJSError:error] forKey:@"error"];
[_emitter sendEventWithName:FIRESTORE_COLLECTION_SYNC_EVENT body:event]; // TODO: Temporary fix for https://github.com/invertase/react-native-firebase/issues/233
// until a better solution comes around
if (_emitter.bridge) {
[_emitter sendEventWithName:FIRESTORE_COLLECTION_SYNC_EVENT body:event];
}
} }
- (void)handleQuerySnapshotEvent:(NSString *)listenerId - (void)handleQuerySnapshotEvent:(NSString *)listenerId
@ -162,7 +166,11 @@ queryListenOptions:(NSDictionary *) queryListenOptions {
[event setValue:listenerId forKey:@"listenerId"]; [event setValue:listenerId forKey:@"listenerId"];
[event setValue:[RNFirebaseFirestoreCollectionReference snapshotToDictionary:querySnapshot] forKey:@"querySnapshot"]; [event setValue:[RNFirebaseFirestoreCollectionReference snapshotToDictionary:querySnapshot] forKey:@"querySnapshot"];
[_emitter sendEventWithName:FIRESTORE_COLLECTION_SYNC_EVENT body:event]; // TODO: Temporary fix for https://github.com/invertase/react-native-firebase/issues/233
// until a better solution comes around
if (_emitter.bridge) {
[_emitter sendEventWithName:FIRESTORE_COLLECTION_SYNC_EVENT body:event];
}
} }
+ (NSDictionary *)snapshotToDictionary:(FIRQuerySnapshot *)querySnapshot { + (NSDictionary *)snapshotToDictionary:(FIRQuerySnapshot *)querySnapshot {

View File

@ -147,7 +147,11 @@ static NSMutableDictionary *_listeners;
[event setValue:listenerId forKey:@"listenerId"]; [event setValue:listenerId forKey:@"listenerId"];
[event setValue:[RNFirebaseFirestore getJSError:error] forKey:@"error"]; [event setValue:[RNFirebaseFirestore getJSError:error] forKey:@"error"];
[_emitter sendEventWithName:FIRESTORE_DOCUMENT_SYNC_EVENT body:event]; // TODO: Temporary fix for https://github.com/invertase/react-native-firebase/issues/233
// until a better solution comes around
if (_emitter.bridge) {
[_emitter sendEventWithName:FIRESTORE_DOCUMENT_SYNC_EVENT body:event];
}
} }
- (void)handleDocumentSnapshotEvent:(NSString *)listenerId - (void)handleDocumentSnapshotEvent:(NSString *)listenerId
@ -158,7 +162,11 @@ static NSMutableDictionary *_listeners;
[event setValue:listenerId forKey:@"listenerId"]; [event setValue:listenerId forKey:@"listenerId"];
[event setValue:[RNFirebaseFirestoreDocumentReference snapshotToDictionary:documentSnapshot] forKey:@"documentSnapshot"]; [event setValue:[RNFirebaseFirestoreDocumentReference snapshotToDictionary:documentSnapshot] forKey:@"documentSnapshot"];
[_emitter sendEventWithName:FIRESTORE_DOCUMENT_SYNC_EVENT body:event]; // TODO: Temporary fix for https://github.com/invertase/react-native-firebase/issues/233
// until a better solution comes around
if (_emitter.bridge) {
[_emitter sendEventWithName:FIRESTORE_DOCUMENT_SYNC_EVENT body:event];
}
} }