|
1 | 1 | import _ from 'underscore'; |
2 | 2 | import Str from 'expensify-common/lib/str'; |
3 | 3 | import lodashMerge from 'lodash/merge'; |
| 4 | +import lodashMergeWith from 'lodash/mergeWith'; |
4 | 5 | import lodashGet from 'lodash/get'; |
5 | 6 | import Storage from './storage'; |
6 | 7 | import * as Logger from './Logger'; |
7 | 8 | import cache from './OnyxCache'; |
8 | 9 | import createDeferredTask from './createDeferredTask'; |
| 10 | +import customizerForMergeWith from './customizerForMergeWith'; |
9 | 11 |
|
10 | 12 | // Keeps track of the last connectionID that was used so we can keep incrementing it |
11 | 13 | let lastConnectionID = 0; |
@@ -661,7 +663,7 @@ function applyMerge(key, data) { |
661 | 663 | if (_.isObject(data) || _.every(mergeValues, _.isObject)) { |
662 | 664 | // Object values are merged one after the other |
663 | 665 | return _.reduce(mergeValues, (modifiedData, mergeValue) => { |
664 | | - const newData = lodashMerge({}, modifiedData, mergeValue); |
| 666 | + const newData = lodashMergeWith({}, modifiedData, mergeValue, customizerForMergeWith); |
665 | 667 |
|
666 | 668 | // We will also delete any object keys that are undefined or null. |
667 | 669 | // Deleting keys is not supported by AsyncStorage so we do it this way. |
@@ -732,7 +734,7 @@ function initializeWithDefaultKeyStates() { |
732 | 734 | .then((pairs) => { |
733 | 735 | const asObject = _.object(pairs); |
734 | 736 |
|
735 | | - const merged = lodashMerge(asObject, defaultKeyStates); |
| 737 | + const merged = lodashMergeWith(asObject, defaultKeyStates, customizerForMergeWith); |
736 | 738 | cache.merge(merged); |
737 | 739 | _.each(merged, (val, key) => keyChanged(key, val)); |
738 | 740 | }); |
|
0 commit comments