POC for GetChats to Calculate simplified report object and simplified IOU reports in Auth#8779
POC for GetChats to Calculate simplified report object and simplified IOU reports in Auth#8779cead22 wants to merge 9 commits into
Conversation
| return fetchChatReportsByIDs(reportIDs); | ||
| // return fetchChatReportsByIDs(reportIDs); | ||
| const simplifiedReports = {}; | ||
| return API.GetChats({reportIDList: reportIDs}) |
There was a problem hiding this comment.
Hmmm this is still doing 2 API calls: 1 to Get chatList and one to GetChats. We could put all the logic in Get chatList, no?
There was a problem hiding this comment.
Yup, I mentioned that in the issue where I asked for the reviews ;)
| // personal details of all the participants and even link up their avatars to report icons. | ||
| const reportIOUData = {}; | ||
| _.each(chats.reportList, (report) => { | ||
| const simplifiedReport = getSimplifiedReportObject(report); |
There was a problem hiding this comment.
I assume removing getSimplifiedReportObject (and massaging the data in auth/php) is out of scope for this PR?
There was a problem hiding this comment.
Yeah
- getSimplifiedReportObject is used in other places
- PersonalDetails->getDisplayName -- the personal details logic could start getting implemented in auth, but I think it's better to keep that out of the scope of this because it would create duplication in PHP and Auth, and this change will be big enough already
- Report_Action_IOU->getMessage, this one is actually one that you pointed out, and if you look at the code there's a lot in there that would need to be moved or duplicated in auth, so leaving that out of scope too
There was a problem hiding this comment.
ok makes sense, so we'll need more refactoring after this one 👍
There was a problem hiding this comment.
random related thing, but probably irrelevant to your refactor @cead22 - this getSimplifiedReportObject() method is also weirdly connected to the unread actions stuff. This method is currently doing two things:
- formatting the data for Onyx
- has some influence over the unread actions indirectly via this code path (which I think is... confusing and am planning to improve)
App/src/libs/actions/Report.js
Line 228 in d8274f5
App/src/libs/actions/Report.js
Lines 97 to 105 in d8274f5
Kind of unexpected that a "get" method would also store this rNVP locally - but there are long list of issues with this stuff so maybe we can just be on the lookout for any weirdness for now.
| // Get all the chat reports if they have any, otherwise create one with concierge | ||
| if (reportIDs.length > 0) { | ||
| return fetchChatReportsByIDs(reportIDs); | ||
| // return fetchChatReportsByIDs(reportIDs); |
There was a problem hiding this comment.
So all the calls to this method will need to be migrated later?
There was a problem hiding this comment.
The other ones, yes. And yes to not leaving commented code, but as I work on this I comment/uncomment 3 lines to go from the old logic to the new logic so I can check the old vs new Onyx data easily, and this is one of those 3 lines
|
I made a new PR because this one had unverified commits #9631 |
Details
Fixed Issues
Tests
PR Review Checklist
Contributor (PR Author) Checklist
### Fixed Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*filesSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */displayNamepropertythisproperly 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)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)PR Reviewer Checklist
### Fixed Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick).src/languages/*filesSTYLE.md) were followed/** comment above it */displayNamepropertythisproperly 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)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)QA Steps
Screenshots
Web
Mobile Web
Desktop
iOS
Android