Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.53k stars 2.88k forks source link

[LHN Mismatch] Add SetCollection to Onyx #51864

Open puneetlath opened 1 week ago

puneetlath commented 1 week ago

We are going to be changing the behavior of OpenApp/ReconnectApp when it does a full reconnect to replace the full reports list that the client has stored instead of merging with it. In order to do that, we need to be able to send a list of report objects to the client and have Onyx.set be called for each of those reports. And have any reports that weren't included get cleared. In order to support this, let's add SetCollection to Onyx.

melvin-bot[bot] commented 1 week ago

Triggered auto assignment to @garrettmknight (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO.

melvin-bot[bot] commented 1 week ago

:warning: It looks like this issue is labelled as a New Feature but not tied to any GitHub Project. Keep in mind that all new features should be tied to GitHub Projects in order to properly track external CAP software time :warning:

melvin-bot[bot] commented 1 week ago

Triggered auto assignment to Design team member for new feature review - @dannymcclain (NewFeature)

zirgulis commented 4 days ago

I am Povilas Zirgulis from Callstack - expert contributor group. I’d like to work on this job

zirgulis commented 3 days ago

@puneetlath should the API for setCollection be something like this?

Onyx.setCollection(ONYXKEYS.COLLECTION.REPORT, [
     { [`${ONYXKEYS.COLLECTION.REPORT}1`]: report1 },
     { [`${ONYXKEYS.COLLECTION.REPORT}2`]: report2 }
 ]);
puneetlath commented 3 days ago

I think the API for it should look basically exactly like mergeCollection. Which I believe would mean it looks like this:

Onyx.setCollection(ONYXKEYS.COLLECTION.REPORT, {
    [`${ONYXKEYS.COLLECTION.REPORT}${report1.reportID}`]: report1,
    [`${ONYXKEYS.COLLECTION.REPORT}${report2.reportID}`]: report2,
    [`${ONYXKEYS.COLLECTION.REPORT}${report3.reportID}`]: report3,
});

Unless there's some reason you think it should be different.

puneetlath commented 1 day ago

How's this going @zirgulis?

zirgulis commented 1 day ago

@puneetlath PR open https://github.com/Expensify/react-native-onyx/pull/594

puneetlath commented 1 day ago

Great!