@react-native-firebase/database 16.0.0 → 16.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [16.1.0](https://github.com/invertase/react-native-firebase/compare/v16.0.0...v16.1.0) (2022-10-20)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **database, useEmulator:** drop multiple calls to useEmulator ([5fcfc44](https://github.com/invertase/react-native-firebase/commit/5fcfc4485e6e44225b144bc517017a61ac2ed40d)), closes [#5650](https://github.com/invertase/react-native-firebase/issues/5650)
11
+
6
12
  ## [16.0.0](https://github.com/invertase/react-native-firebase/compare/v15.7.1...v16.0.0) (2022-10-19)
7
13
 
8
14
  **Note:** Version bump only for package @react-native-firebase/database
@@ -46,9 +46,14 @@ public class UniversalFirebaseDatabaseCommon {
46
46
  setDatabaseConfig(firebaseDatabase, appName, dbURL);
47
47
 
48
48
  HashMap emulatorConfig = getEmulatorConfig(appName, dbURL);
49
- if (emulatorConfig != null) {
49
+
50
+ if (emulatorConfig != null && emulatorConfig.get("configured") == null) {
50
51
  firebaseDatabase.useEmulator(
51
52
  (String) emulatorConfig.get("host"), (Integer) emulatorConfig.get("port"));
53
+ // The underlying SDK may only be configured once, but with hot-reloads in the
54
+ // javascript bundle, javascript cannot hold SDK configuration state. Keep track here
55
+ // so we only configure once
56
+ emulatorConfig.put("configured", "true");
52
57
  }
53
58
 
54
59
  return firebaseDatabase;
@@ -22,6 +22,8 @@
22
22
  #import "RNFBDatabaseModule.h"
23
23
  #import "RNFBPreferences.h"
24
24
 
25
+ static __strong NSMutableDictionary *emulatorSettings;
26
+
25
27
  @implementation RNFBDatabaseModule
26
28
  #pragma mark -
27
29
  #pragma mark Module Setup
@@ -58,8 +60,22 @@ RCT_EXPORT_METHOD(useEmulator
58
60
  : (NSString *)dbURL
59
61
  : (nonnull NSString *)host
60
62
  : (NSInteger)port) {
61
- [[RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL] useEmulatorWithHost:host
62
- port:port];
63
+ // javascript may hot reload, losing state, and native throws an error if you double-request
64
+ // so we keep track of useEmulator calls here to avoid calling native twice
65
+ if (emulatorSettings == nil) {
66
+ emulatorSettings = [NSMutableDictionary dictionary];
67
+ }
68
+
69
+ NSMutableString *configKey = [firebaseApp.name mutableCopy];
70
+ if (dbURL != nil && dbURL.length > 0) {
71
+ [configKey appendString:dbURL];
72
+ }
73
+
74
+ if (!emulatorSettings[configKey]) {
75
+ [[RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL] useEmulatorWithHost:host
76
+ port:port];
77
+ emulatorSettings[configKey] = @YES;
78
+ }
63
79
  }
64
80
 
65
81
  RCT_EXPORT_METHOD(setPersistenceEnabled
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- module.exports = '16.0.0';
2
+ module.exports = '16.1.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/database",
3
- "version": "16.0.0",
3
+ "version": "16.1.0",
4
4
  "author": "Invertase <oss@invertase.io> (http://invertase.io)",
5
5
  "description": "React Native Firebase - The Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON and synchronized in realtime to every connected client. React Native Firebase provides native integration with the Android & iOS Firebase SDKs, supporting both realtime data sync and offline capabilities.",
6
6
  "main": "lib/index.js",
@@ -25,10 +25,10 @@
25
25
  "realtome database"
26
26
  ],
27
27
  "peerDependencies": {
28
- "@react-native-firebase/app": "16.0.0"
28
+ "@react-native-firebase/app": "16.1.0"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"
32
32
  },
33
- "gitHead": "fe2bebee106dc178b0835f7097c2d05b30223b2f"
33
+ "gitHead": "f2d1363b89fb046388f8336b08852c1ea0c285f2"
34
34
  }