@react-native-firebase/storage 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
+ - **storage, emulator:** avoid calling useEmulator multiple times ([276630d](https://github.com/invertase/react-native-firebase/commit/276630d4690cb6c3b2b632ec9dd0808ca8013eba)), closes [#5860](https://github.com/invertase/react-native-firebase/issues/5860)
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/storage
@@ -44,6 +44,8 @@ import java.util.Objects;
44
44
  public class ReactNativeFirebaseStorageModule extends ReactNativeFirebaseModule {
45
45
  private static final String TAG = "Storage";
46
46
 
47
+ private static HashMap<String, String> emulatorConfigs = new HashMap<>();
48
+
47
49
  ReactNativeFirebaseStorageModule(ReactApplicationContext reactContext) {
48
50
  super(reactContext, TAG);
49
51
  }
@@ -54,7 +56,9 @@ public class ReactNativeFirebaseStorageModule extends ReactNativeFirebaseModule
54
56
  super.onCatalystInstanceDestroy();
55
57
  }
56
58
 
57
- /** @link https://firebase.google.com/docs/reference/js/firebase.storage.Reference#delete */
59
+ /**
60
+ * @link https://firebase.google.com/docs/reference/js/firebase.storage.Reference#delete
61
+ */
58
62
  @ReactMethod
59
63
  public void delete(String appName, String url, final Promise promise) {
60
64
  try {
@@ -97,7 +101,9 @@ public class ReactNativeFirebaseStorageModule extends ReactNativeFirebaseModule
97
101
  }
98
102
  }
99
103
 
100
- /** @link https://firebase.google.com/docs/reference/js/firebase.storage.Reference#getMetadata */
104
+ /**
105
+ * @link https://firebase.google.com/docs/reference/js/firebase.storage.Reference#getMetadata
106
+ */
101
107
  @ReactMethod
102
108
  public void getMetadata(String appName, String url, Promise promise) {
103
109
  try {
@@ -118,7 +124,9 @@ public class ReactNativeFirebaseStorageModule extends ReactNativeFirebaseModule
118
124
  }
119
125
  }
120
126
 
121
- /** @link https://firebase.google.com/docs/reference/js/firebase.storage.Reference#list */
127
+ /**
128
+ * @link https://firebase.google.com/docs/reference/js/firebase.storage.Reference#list
129
+ */
122
130
  @ReactMethod
123
131
  public void list(String appName, String url, ReadableMap listOptions, Promise promise) {
124
132
  try {
@@ -148,7 +156,9 @@ public class ReactNativeFirebaseStorageModule extends ReactNativeFirebaseModule
148
156
  }
149
157
  }
150
158
 
151
- /** @link https://firebase.google.com/docs/reference/js/firebase.storage.Reference#listAll */
159
+ /**
160
+ * @link https://firebase.google.com/docs/reference/js/firebase.storage.Reference#listAll
161
+ */
152
162
  @ReactMethod
153
163
  public void listAll(String appName, String url, Promise promise) {
154
164
  try {
@@ -267,16 +277,23 @@ public class ReactNativeFirebaseStorageModule extends ReactNativeFirebaseModule
267
277
  promise.resolve(null);
268
278
  }
269
279
 
270
- /** @link https://firebase.google.com/docs/reference/js/firebase.storage.Storage#useEmulator */
280
+ /**
281
+ * @link https://firebase.google.com/docs/reference/js/firebase.storage.Storage#useEmulator
282
+ */
271
283
  @ReactMethod
272
284
  public void useEmulator(String appName, String host, int port, Promise promise) {
273
285
  FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
274
286
  FirebaseStorage firebaseStorage = FirebaseStorage.getInstance(firebaseApp);
275
- firebaseStorage.useEmulator(host, port);
287
+ if (emulatorConfigs.get(appName) == null) {
288
+ firebaseStorage.useEmulator(host, port);
289
+ emulatorConfigs.put(appName, "true");
290
+ }
276
291
  promise.resolve(null);
277
292
  }
278
293
 
279
- /** @link https://firebase.google.com/docs/reference/js/firebase.storage.Reference#writeToFile */
294
+ /**
295
+ * @link https://firebase.google.com/docs/reference/js/firebase.storage.Reference#writeToFile
296
+ */
280
297
  @ReactMethod
281
298
  public void writeToFile(
282
299
  String appName, String url, String localFilePath, int taskId, Promise promise) {
@@ -300,7 +317,9 @@ public class ReactNativeFirebaseStorageModule extends ReactNativeFirebaseModule
300
317
  }
301
318
  }
302
319
 
303
- /** @link https://firebase.google.com/docs/reference/js/firebase.storage.Reference#putString */
320
+ /**
321
+ * @link https://firebase.google.com/docs/reference/js/firebase.storage.Reference#putString
322
+ */
304
323
  @ReactMethod
305
324
  public void putString(
306
325
  String appName,
@@ -321,7 +340,9 @@ public class ReactNativeFirebaseStorageModule extends ReactNativeFirebaseModule
321
340
  }
322
341
  }
323
342
 
324
- /** @link https://firebase.google.com/docs/reference/js/firebase.storage.Reference#putFile */
343
+ /**
344
+ * @link https://firebase.google.com/docs/reference/js/firebase.storage.Reference#putFile
345
+ */
325
346
  @ReactMethod
326
347
  public void putFile(
327
348
  String appName,
@@ -35,7 +35,7 @@ static NSMutableDictionary *PENDING_TASKS;
35
35
  // The iOS SDK has a short memory on settings, store these globally and set them in each time
36
36
  static NSString *emulatorHost = nil;
37
37
  static NSInteger emulatorPort = 0;
38
- static bool useEmulatorCalled = false;
38
+ static NSMutableDictionary *emulatorConfigs;
39
39
  static NSTimeInterval maxDownloadRetryTime = 600;
40
40
  static NSTimeInterval maxUploadRetryTime = 600;
41
41
  static NSTimeInterval maxOperationRetryTime = 120;
@@ -56,6 +56,7 @@ RCT_EXPORT_MODULE();
56
56
  static dispatch_once_t onceToken;
57
57
  dispatch_once(&onceToken, ^{
58
58
  PENDING_TASKS = [[NSMutableDictionary alloc] init];
59
+ emulatorConfigs = [[NSMutableDictionary alloc] init];
59
60
  });
60
61
 
61
62
  return self;
@@ -506,12 +507,10 @@ RCT_EXPORT_METHOD(useEmulator
506
507
  : (NSInteger)port) {
507
508
  emulatorHost = host;
508
509
  emulatorPort = port;
509
- if (useEmulatorCalled == true) {
510
- return;
510
+ if (!emulatorConfigs[firebaseApp.name]) {
511
+ [[FIRStorage storageForApp:firebaseApp] useEmulatorWithHost:host port:port];
512
+ emulatorConfigs[firebaseApp.name] = @YES;
511
513
  }
512
-
513
- [[FIRStorage storageForApp:firebaseApp] useEmulatorWithHost:host port:port];
514
- useEmulatorCalled = true;
515
514
  }
516
515
 
517
516
  /**
@@ -669,10 +668,11 @@ RCT_EXPORT_METHOD(setTaskStatus
669
668
  storage = [FIRStorage storageForApp:firebaseApp URL:bucket];
670
669
 
671
670
  NSLog(@"Setting emulator - host %@ port %ld", emulatorHost, (long)emulatorPort);
672
- if (![emulatorHost isEqual:[NSNull null]] && emulatorHost != nil && useEmulatorCalled == false) {
671
+ if (![emulatorHost isEqual:[NSNull null]] && emulatorHost != nil &&
672
+ !emulatorConfigs[firebaseApp.name]) {
673
673
  @try {
674
674
  [storage useEmulatorWithHost:emulatorHost port:emulatorPort];
675
- useEmulatorCalled = true;
675
+ emulatorConfigs[firebaseApp.name] = @YES;
676
676
  } @catch (NSException *e) {
677
677
  NSLog(@"WARNING: Unable to set the Firebase Storage emulator settings. These must be set "
678
678
  @"before any usages of Firebase Storage. If you see this log after a hot "
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/storage",
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 - React Native Firebase provides native integration with Cloud Storage, providing support to upload and download files directly from your device and from your Firebase Cloud Storage bucket.",
6
6
  "main": "lib/index.js",
@@ -29,10 +29,10 @@
29
29
  "download"
30
30
  ],
31
31
  "peerDependencies": {
32
- "@react-native-firebase/app": "16.0.0"
32
+ "@react-native-firebase/app": "16.1.0"
33
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "fe2bebee106dc178b0835f7097c2d05b30223b2f"
37
+ "gitHead": "f2d1363b89fb046388f8336b08852c1ea0c285f2"
38
38
  }