Merge branch 'master' of https://github.com/invertase/react-native-firebase
# Conflicts: # lib/utils/SyncTree.js
This commit is contained in:
commit
e6a01aedb3
|
@ -13,6 +13,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
|||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
|
||||
import com.google.firebase.FirebaseApp;
|
||||
import com.google.firebase.database.DatabaseException;
|
||||
import com.google.firebase.database.Logger;
|
||||
import com.google.firebase.database.MutableData;
|
||||
import com.google.firebase.database.OnDisconnect;
|
||||
|
@ -35,6 +36,7 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
|
|||
private static final String TAG = "RNFirebaseDatabase";
|
||||
private boolean enableLogging = false;
|
||||
private HashMap<String, RNFirebaseDatabaseReference> references = new HashMap<>();
|
||||
private HashMap<String, Boolean> loggingLevelSet = new HashMap<>();
|
||||
private SparseArray<RNFirebaseTransactionHandler> transactionHandlers = new SparseArray<>();
|
||||
|
||||
RNFirebaseDatabase(ReactApplicationContext reactContext) {
|
||||
|
@ -89,6 +91,8 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
|
|||
enableLogging = enabled;
|
||||
List<FirebaseApp> firebaseAppList = FirebaseApp.getApps(getReactApplicationContext());
|
||||
for (FirebaseApp app : firebaseAppList) {
|
||||
loggingLevelSet.put(app.getName(), enabled);
|
||||
|
||||
if (enableLogging) {
|
||||
FirebaseDatabase.getInstance(app).setLogLevel(Logger.Level.DEBUG);
|
||||
} else {
|
||||
|
@ -488,12 +492,21 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
|
|||
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
|
||||
FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance(firebaseApp);
|
||||
|
||||
// todo errors 'calls must be made before any other usage of database instance
|
||||
// if (enableLogging) {
|
||||
// firebaseDatabase.setLogLevel(Logger.Level.DEBUG);
|
||||
// } else {
|
||||
// firebaseDatabase.setLogLevel(Logger.Level.WARN);
|
||||
// }
|
||||
if (enableLogging && !loggingLevelSet.get(firebaseDatabase.getApp().getName())) {
|
||||
try {
|
||||
loggingLevelSet.put(firebaseDatabase.getApp().getName(), enableLogging);
|
||||
firebaseDatabase.setLogLevel(Logger.Level.DEBUG);
|
||||
} catch (DatabaseException dex) {
|
||||
// do nothing - to catch 'calls to setLogLevel must be made for use of database' errors
|
||||
}
|
||||
} else if (!enableLogging && loggingLevelSet.get(firebaseDatabase.getApp().getName())) {
|
||||
try {
|
||||
loggingLevelSet.put(firebaseDatabase.getApp().getName(), enableLogging);
|
||||
firebaseDatabase.setLogLevel(Logger.Level.WARN);
|
||||
} catch (DatabaseException dex) {
|
||||
// do nothing - to catch 'calls to setLogLevel must be made for use of database' errors
|
||||
}
|
||||
}
|
||||
|
||||
return firebaseDatabase;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.WritableArray;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
|
@ -27,7 +26,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import io.invertase.firebase.ErrorUtils;
|
||||
import io.invertase.firebase.Utils;
|
||||
|
||||
|
||||
public class RNFirebaseFirestore extends ReactContextBaseJavaModule {
|
||||
|
@ -42,6 +40,16 @@ public class RNFirebaseFirestore extends ReactContextBaseJavaModule {
|
|||
/*
|
||||
* REACT NATIVE METHODS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param enabled
|
||||
*/
|
||||
@ReactMethod
|
||||
public void enableLogging(Boolean enabled) {
|
||||
FirebaseFirestore.setLoggingEnabled(enabled);
|
||||
}
|
||||
|
||||
|
||||
@ReactMethod
|
||||
public void collectionGet(String appName, String path, ReadableArray filters,
|
||||
ReadableArray orders, ReadableMap options, final Promise promise) {
|
||||
|
|
|
@ -18,6 +18,10 @@ RCT_EXPORT_MODULE();
|
|||
return self;
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(enableLogging:(BOOL) enabled) {
|
||||
[FIRFirestore enableLogging:enabled];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(collectionGet:(NSString *) appName
|
||||
path:(NSString *) path
|
||||
filters:(NSArray *) filters
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* @flow
|
||||
* Firestore representation wrapper
|
||||
*/
|
||||
import { NativeModules } from 'react-native';
|
||||
|
||||
import ModuleBase from './../../utils/ModuleBase';
|
||||
import CollectionReference from './CollectionReference';
|
||||
import DocumentReference from './DocumentReference';
|
||||
|
@ -143,4 +145,9 @@ export default class Firestore extends FirestoreInternalModule {
|
|||
export const statics = {
|
||||
FieldValue,
|
||||
GeoPoint,
|
||||
enableLogging(bool) {
|
||||
if (NativeModules[Firestore._NATIVE_MODULE]) {
|
||||
NativeModules[Firestore._NATIVE_MODULE].enableLogging(bool);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -72,7 +72,7 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
project.ext.firebaseVersion = '11.4.2'
|
||||
project.ext.firebaseVersion = '11.6.2'
|
||||
|
||||
dependencies {
|
||||
// compile(project(':react-native-firebase')) {
|
||||
|
|
Loading…
Reference in New Issue