diff --git a/android/src/main/java/io/invertase/firebase/database/RNFirebaseDatabase.java b/android/src/main/java/io/invertase/firebase/database/RNFirebaseDatabase.java index c9e5a41a..3880c66c 100644 --- a/android/src/main/java/io/invertase/firebase/database/RNFirebaseDatabase.java +++ b/android/src/main/java/io/invertase/firebase/database/RNFirebaseDatabase.java @@ -35,9 +35,9 @@ import io.invertase.firebase.Utils; public class RNFirebaseDatabase extends ReactContextBaseJavaModule { private static final String TAG = "RNFirebaseDatabase"; - private boolean enableLogging = false; + private static boolean enableLogging = false; private HashMap references = new HashMap<>(); - private HashMap loggingLevelSet = new HashMap<>(); + private static HashMap loggingLevelSet = new HashMap<>(); private SparseArray transactionHandlers = new SparseArray<>(); RNFirebaseDatabase(ReactApplicationContext reactContext) { @@ -54,7 +54,7 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule { */ @ReactMethod public void goOnline(String appName, String dbURL) { - getDatabaseForAppAndSetLogging(appName, dbURL).goOnline(); + getDatabaseForApp(appName, dbURL).goOnline(); } /** @@ -62,7 +62,7 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule { */ @ReactMethod public void goOffline(String appName, String dbURL) { - getDatabaseForAppAndSetLogging(appName, dbURL).goOffline(); + getDatabaseForApp(appName, dbURL).goOffline(); } /** @@ -71,7 +71,7 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule { */ @ReactMethod public void setPersistence(String appName, String dbURL, Boolean state) { - getDatabaseForAppAndSetLogging(appName, dbURL).setPersistenceEnabled(state); + getDatabaseForApp(appName, dbURL).setPersistenceEnabled(state); } /** @@ -80,7 +80,7 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule { */ @ReactMethod public void setPersistenceCacheSizeBytes(String appName, String dbURL, int size) { - getDatabaseForAppAndSetLogging(appName, dbURL).setPersistenceCacheSizeBytes((long) size); + getDatabaseForApp(appName, dbURL).setPersistenceCacheSizeBytes((long) size); } @@ -506,18 +506,6 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule { firebaseDatabase = FirebaseDatabase.getInstance(firebaseApp); } - return firebaseDatabase; - } - - /** - * Get a database instance for a specific firebase app instance and enable/disable logging - * - * @param appName - * @param dbURL - * @return - */ - private FirebaseDatabase getDatabaseForAppAndSetLogging(String appName, String dbURL) { - FirebaseDatabase firebaseDatabase = RNFirebaseDatabase.getDatabaseForApp(appName, dbURL); Boolean logLevel = loggingLevelSet.get(firebaseDatabase.getApp().getName()); if (enableLogging && (logLevel == null || !logLevel)) { @@ -555,7 +543,7 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule { * @return */ private DatabaseReference getReferenceForAppPath(String appName, String dbURL, String path) { - return getDatabaseForAppAndSetLogging(appName, dbURL).getReference(path); + return getDatabaseForApp(appName, dbURL).getReference(path); } /** diff --git a/lib/modules/database/index.js b/lib/modules/database/index.js index 66dc05fc..fb198588 100644 --- a/lib/modules/database/index.js +++ b/lib/modules/database/index.js @@ -34,7 +34,7 @@ export default class Database extends ModuleBase { let serviceUrl; if (typeof appOrUrl === 'string') { app = firebase.app(); - serviceUrl = appOrUrl; + serviceUrl = appOrUrl.endsWith('/') ? appOrUrl : `${appOrUrl}/`; } else { app = appOrUrl; serviceUrl = app.options.databaseURL;