react-native-onyx 2.0.70 → 2.0.72

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.
@@ -48,16 +48,21 @@ class OnyxConnectionManager {
48
48
  * according to their purpose and effect they produce in the Onyx connection.
49
49
  */
50
50
  generateConnectionID(connectOptions) {
51
- var _a, _b;
51
+ const { key, initWithStoredValues, reuseConnection, waitForCollectionCallback } = connectOptions;
52
52
  let suffix = '';
53
53
  // We will generate a unique ID in any of the following situations:
54
- // - `connectOptions.reuseConnection` is `false`. That means the subscriber explicitly wants the connection to not be reused.
55
- // - `connectOptions.initWithStoredValues` is `false`. This flag changes the subscription flow when set to `false`, so the connection can't be reused.
54
+ // - `reuseConnection` is `false`. That means the subscriber explicitly wants the connection to not be reused.
55
+ // - `initWithStoredValues` is `false`. This flag changes the subscription flow when set to `false`, so the connection can't be reused.
56
+ // - `key` is a collection key AND `waitForCollectionCallback` is `undefined/false`. This combination needs a new connection at every subscription
57
+ // in order to send all the collection entries, so the connection can't be reused.
56
58
  // - `withOnyxInstance` is defined inside `connectOptions`. That means the subscriber is a `withOnyx` HOC and therefore doesn't support connection reuse.
57
- if (connectOptions.reuseConnection === false || connectOptions.initWithStoredValues === false || utils_1.default.hasWithOnyxInstance(connectOptions)) {
59
+ if (reuseConnection === false ||
60
+ initWithStoredValues === false ||
61
+ (!utils_1.default.hasWithOnyxInstance(connectOptions) && OnyxUtils_1.default.isCollectionKey(key) && (waitForCollectionCallback === undefined || waitForCollectionCallback === false)) ||
62
+ utils_1.default.hasWithOnyxInstance(connectOptions)) {
58
63
  suffix += `,uniqueID=${Str.guid()}`;
59
64
  }
60
- return `onyxKey=${connectOptions.key},initWithStoredValues=${(_a = connectOptions.initWithStoredValues) !== null && _a !== void 0 ? _a : true},waitForCollectionCallback=${(_b = connectOptions.waitForCollectionCallback) !== null && _b !== void 0 ? _b : false}${suffix}`;
65
+ return `onyxKey=${key},initWithStoredValues=${initWithStoredValues !== null && initWithStoredValues !== void 0 ? initWithStoredValues : true},waitForCollectionCallback=${waitForCollectionCallback !== null && waitForCollectionCallback !== void 0 ? waitForCollectionCallback : false}${suffix}`;
61
66
  }
62
67
  /**
63
68
  * Fires all the subscribers callbacks associated with that connection ID.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "2.0.70",
3
+ "version": "2.0.72",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",