Fix inconsistencies between single key operations (merge, set) and multi key operations (mergeCollection, multiSet)#519
Conversation
…en-single-and-multi-functions
merge, set) and multi (mergeCollection, multiSet) functionsmerge, set) and multi (mergeCollection, multiSet) functions
|
I'm placing this on HOLD right now in order for QA to be done on the latest version of Onyx without more un-QAed PRs from being merged. |
|
@chrispader I'm getting this error when launching the App:
|
I integrated #515 into this PR, so this should be the last PR in Onyx before we can bump it in E/App. |
done! can't thoroughly test it right now, will do in the evening. lmk if something doesn't work |
…en-single-and-multi-functions
|
@chrispader are there no manual tests that could be done here? @rinej seems like the reassure action here is not happy yet, could you check out the failure? |
hmm, not really, since we're testing for that in the Jest tests already. You could manually run the steps to check for this behavior either in the DevTools console or somewhere in E/App. I added the steps to |
merge, set) and multi key operations (mergeCollection, multiSet)merge, set) and multi key operations (mergeCollection, multiSet)
|
Removed the hold, lets ignore the reassure tests as we are just setting them up in the repo to make sure the lower level functions stay performant, however the setup does not look 100% yet, @rinej from Callstack will investigate on Monday @tgolen @MonilBhavsar please continue with the review |
|
@tgolen I believe it's only pending your re-approval now? |
@tgolen already approved, i just changed a minor NAB mentioned by @MonilBhavsar. no critical change |
|
Welp, somebody's gotta merge it anyway🙂 |
|
haha, OK. Here I go! |
|
🚀Published to npm in v2.0.33 |
|
@francoisl reported that we had to roll back Onyx due to a regression in this PR. @chrispader can you please work on fixing this issue and creating a new PR to upgrade Onyx? This is currently preventing us from deploying other Onyx changes. |
|
Looking into fixing the regression and bumping Onyx today/tomorrow! |
|
Sorry for the delay 🙈 Working on this now! |
|
Fixed in Expensify/App#42057 |

@paultsimura
Details
This PR aims to remove inconsistencies between "single key operations" (
merge,set, ...) and "multi key operations" (mergeCollection, which usesmultiMergeunder the hood,multiSet, ...).When using
mergeCollectionnested null values would not be removed from storage, because we already removed thenullvalues from the changes in that are then later (natively) merged in the provider. Keeping thenullvalues in the changes sent to the storage layer ensures, that the same data will be written, as when we usedmerge.This PR also makes sure that nested
nullvalues that we get from cache are never sent to the user (e.g. withwithOnyx,useOnyxor a callback). Cache in Onyx will still containnullvalues for performance reasons, as in #411. We can still use the original data to compare data to prevent unnecessary re-renders, but we should never providenullvalues towithOnyxprops or callbacks.This PR also adds some more unit tests to check for these new changes.
Related Issues
$ #516
$ #514
Automated Tests
Run Jest tests especially the ones in
oynxTestregardingmergeCollection.Manual Tests
Somewhere in E/App or any other test project:
Onyx.mergeCollectionwith nested null values for already existing keys.Onyx.connector the valuef fromuseOnyx/withOnyxAuthor Checklist
### Related Issuessection aboveTestssectiontoggleReportand notonIconClick)myBool && <MyComponent />.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)Avataris modified, I verified thatAvataris working as expected in all cases)mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop