react-native-onyx 2.0.58 → 2.0.60

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/dist/Onyx.js CHANGED
@@ -482,21 +482,24 @@ function mergeCollection(collectionKey, collection) {
482
482
  * @param keysToPreserve is a list of ONYXKEYS that should not be cleared with the rest of the data
483
483
  */
484
484
  function clear(keysToPreserve = []) {
485
+ const defaultKeyStates = OnyxUtils_1.default.getDefaultKeyStates();
486
+ const initialKeys = Object.keys(defaultKeyStates);
485
487
  return OnyxUtils_1.default.getAllKeys()
486
- .then((keys) => {
488
+ .then((cachedKeys) => {
487
489
  OnyxCache_1.default.clearNullishStorageKeys();
488
490
  const keysToBeClearedFromStorage = [];
489
491
  const keyValuesToResetAsCollection = {};
490
492
  const keyValuesToResetIndividually = {};
493
+ const allKeys = new Set([...cachedKeys, ...initialKeys]);
491
494
  // The only keys that should not be cleared are:
492
495
  // 1. Anything specifically passed in keysToPreserve (because some keys like language preferences, offline
493
496
  // status, or activeClients need to remain in Onyx even when signed out)
494
497
  // 2. Any keys with a default state (because they need to remain in Onyx as their default, and setting them
495
498
  // to null would cause unknown behavior)
496
- keys.forEach((key) => {
499
+ // 2.1 However, if a default key was explicitly set to null, we need to reset it to the default value
500
+ allKeys.forEach((key) => {
497
501
  var _a;
498
502
  const isKeyToPreserve = keysToPreserve.includes(key);
499
- const defaultKeyStates = OnyxUtils_1.default.getDefaultKeyStates();
500
503
  const isDefaultKey = key in defaultKeyStates;
501
504
  // If the key is being removed or reset to default:
502
505
  // 1. Update it in the cache
@@ -533,7 +536,6 @@ function clear(keysToPreserve = []) {
533
536
  Object.entries(keyValuesToResetAsCollection).forEach(([key, value]) => {
534
537
  updatePromises.push(OnyxUtils_1.default.scheduleNotifyCollectionSubscribers(key, value));
535
538
  });
536
- const defaultKeyStates = OnyxUtils_1.default.getDefaultKeyStates();
537
539
  const defaultKeyValuePairs = Object.entries(Object.keys(defaultKeyStates)
538
540
  .filter((key) => !keysToPreserve.includes(key))
539
541
  .reduce((obj, key) => {
package/dist/OnyxUtils.js CHANGED
@@ -280,6 +280,7 @@ function deleteKeyByConnections(connectionID) {
280
280
  const updatedConnectionIDs = onyxKeyToConnectionIDs.get(subscriber.key).filter((id) => id !== connectionID);
281
281
  onyxKeyToConnectionIDs.set(subscriber.key, updatedConnectionIDs);
282
282
  }
283
+ lastConnectionCallbackData.delete(connectionID);
283
284
  }
284
285
  /** Returns current key names stored in persisted storage */
285
286
  function getAllKeys() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "2.0.58",
3
+ "version": "2.0.60",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",