react-native-onyx 1.0.49 → 1.0.51

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.
@@ -1300,6 +1300,17 @@ function update(data) {
1300
1300
  return clearPromise.then(() => Promise.all(underscore__WEBPACK_IMPORTED_MODULE_2___default().map(promises, (p) => p())));
1301
1301
  }
1302
1302
 
1303
+ /**
1304
+ * When set these keys will not be persisted to storage
1305
+ * @param {string[]} keyList
1306
+ */
1307
+ function setMemoryOnlyKeys(keyList) {
1308
+ _storage__WEBPACK_IMPORTED_MODULE_5__["default"].setMemoryOnlyKeys(keyList);
1309
+
1310
+ // When in memory only mode for certain keys we do not want to ever drop items from the cache as the user will have no way to recover them again via storage.
1311
+ _OnyxCache__WEBPACK_IMPORTED_MODULE_4__["default"].setRecentKeysLimit(Infinity);
1312
+ }
1313
+
1303
1314
  /**
1304
1315
  * Initialize the store with actions and listening for storage events
1305
1316
  *
@@ -1387,7 +1398,8 @@ const Onyx = {
1387
1398
  addToEvictionBlockList,
1388
1399
  removeFromEvictionBlockList,
1389
1400
  isSafeEvictionKey,
1390
- METHOD
1401
+ METHOD,
1402
+ setMemoryOnlyKeys
1391
1403
  };
1392
1404
 
1393
1405
  /**
@@ -2132,7 +2144,8 @@ __webpack_require__.r(__webpack_exports__);
2132
2144
  /* harmony import */ var localforage_removeitems__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! localforage-removeitems */ "localforage-removeitems");
2133
2145
  /* harmony import */ var localforage_removeitems__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(localforage_removeitems__WEBPACK_IMPORTED_MODULE_2__);
2134
2146
  /* harmony import */ var _SyncQueue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../SyncQueue */ "./lib/SyncQueue.js");
2135
- /* harmony import */ var _fastMerge__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../fastMerge */ "./lib/fastMerge.js");
2147
+ /* harmony import */ var _Str__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Str */ "./lib/Str.js");
2148
+ /* harmony import */ var _fastMerge__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../fastMerge */ "./lib/fastMerge.js");
2136
2149
  /**
2137
2150
  * @file
2138
2151
  * The storage provider based on localforage allows us to store most anything in its
@@ -2145,12 +2158,18 @@ __webpack_require__.r(__webpack_exports__);
2145
2158
 
2146
2159
 
2147
2160
 
2161
+
2148
2162
  (0,localforage_removeitems__WEBPACK_IMPORTED_MODULE_2__.extendPrototype)((localforage__WEBPACK_IMPORTED_MODULE_0___default()));
2149
2163
 
2150
2164
  localforage__WEBPACK_IMPORTED_MODULE_0___default().config({
2151
2165
  name: 'OnyxDB'
2152
2166
  });
2153
2167
 
2168
+ /**
2169
+ * Keys that will not ever be persisted to disk.
2170
+ */
2171
+ let memoryOnlyKeys = [];
2172
+
2154
2173
  const provider = {
2155
2174
  /**
2156
2175
  * Writing very quickly to IndexedDB causes performance issues and can lock up the page and lead to jank.
@@ -2158,6 +2177,10 @@ const provider = {
2158
2177
  * to the next.
2159
2178
  */
2160
2179
  setItemQueue: new _SyncQueue__WEBPACK_IMPORTED_MODULE_3__["default"]((_ref) => {let { key, value, shouldMerge } = _ref;
2180
+ if (underscore__WEBPACK_IMPORTED_MODULE_1___default().find(memoryOnlyKeys, (noCacheKey) => _Str__WEBPACK_IMPORTED_MODULE_4__.startsWith(key, noCacheKey))) {
2181
+ return Promise.resolve();
2182
+ }
2183
+
2161
2184
  if (shouldMerge) {
2162
2185
  return localforage__WEBPACK_IMPORTED_MODULE_0___default().getItem(key).
2163
2186
  then((existingValue) => {
@@ -2165,7 +2188,7 @@ const provider = {
2165
2188
 
2166
2189
  // lodash adds a small overhead so we don't use it here
2167
2190
  // eslint-disable-next-line prefer-object-spread, rulesdir/prefer-underscore-method
2168
- ? Object.assign({}, (0,_fastMerge__WEBPACK_IMPORTED_MODULE_4__["default"])(existingValue, value)) :
2191
+ ? Object.assign({}, (0,_fastMerge__WEBPACK_IMPORTED_MODULE_5__["default"])(existingValue, value)) :
2169
2192
  value;
2170
2193
  return localforage__WEBPACK_IMPORTED_MODULE_0___default().setItem(key, newValue);
2171
2194
  });
@@ -2259,6 +2282,13 @@ const provider = {
2259
2282
  */
2260
2283
  setItem(key, value) {
2261
2284
  return this.setItemQueue.push({ key, value });
2285
+ },
2286
+
2287
+ /**
2288
+ * @param {string[]} keyList
2289
+ */
2290
+ setMemoryOnlyKeys(keyList) {
2291
+ memoryOnlyKeys = keyList;
2262
2292
  }
2263
2293
  };
2264
2294