-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Update optimistic data for parent report when adding comment #20762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
605b92b
update optimistic data for parent report action when add comment in t…
dukenv0307 b1feabd
Merge branch 'main' into fix/19445
dukenv0307 7a76df9
migrate child oldest four accountIDs
dukenv0307 d49491f
Merge branch 'main' into fix/19445
dukenv0307 65c5bf8
update parent report action for deleting action
dukenv0307 bea0b78
fix childVisibleActionCount
dukenv0307 331df50
Merge branch 'main' into fix/19445
dukenv0307 a4d9111
update parent report action for all case
dukenv0307 3b49b05
refactor code of function
dukenv0307 28db4ca
Merge branch 'main' into fix/19445
dukenv0307 0b0f688
check parentReportAction carefully
dukenv0307 4351dcb
Merge branch 'main' into fix/19445
dukenv0307 c34ed38
clear condition
dukenv0307 e7a6d7e
change style in line
dukenv0307 af8a97c
Merge branch 'main' into fix/19445
dukenv0307 7263151
fix bug
dukenv0307 0f41743
merge main
dukenv0307 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1339,6 +1339,49 @@ function buildOptimisticAddCommentReportAction(text, file) { | |
| }; | ||
| } | ||
|
|
||
| /** | ||
| * update optimistic parent reportAction when a comment is added or remove in the child report | ||
| * @param {String} parentReportAction - Parent report action of the child report | ||
| * @param {String} lastVisibleActionCreated - Last visible action created of the child report | ||
| * @param {String} type - The type of action in the child report | ||
| * @returns {Object} | ||
| */ | ||
|
|
||
| function updateOptimisticParentReportAction(parentReportAction, lastVisibleActionCreated, type) { | ||
| let childVisibleActionCount = parentReportAction.childVisibleActionCount || 0; | ||
| let childCommenterCount = parentReportAction.childCommenterCount || 0; | ||
| let childOldestFourAccountIDs = parentReportAction.childOldestFourAccountIDs; | ||
|
|
||
| if (type === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) { | ||
| childVisibleActionCount += 1; | ||
| const oldestFourAccountIDs = childOldestFourAccountIDs ? childOldestFourAccountIDs.split(',') : []; | ||
| if (oldestFourAccountIDs.length < 4) { | ||
| const index = _.findIndex(oldestFourAccountIDs, (accountID) => accountID === currentUserAccountID.toString()); | ||
| if (index === -1) { | ||
| childCommenterCount += 1; | ||
| oldestFourAccountIDs.push(currentUserAccountID); | ||
| } | ||
| } | ||
| childOldestFourAccountIDs = oldestFourAccountIDs.join(','); | ||
| } else if (type === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { | ||
| if (childVisibleActionCount > 0) { | ||
| childVisibleActionCount -= 1; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, we consider removal of only one action but multiple actions could be removed. We fixed this in #66786 |
||
| } | ||
|
|
||
| if (childVisibleActionCount === 0) { | ||
|
stitesExpensify marked this conversation as resolved.
|
||
| childCommenterCount = 0; | ||
| childOldestFourAccountIDs = ''; | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| childVisibleActionCount, | ||
| childCommenterCount, | ||
| childLastVisibleActionCreated: lastVisibleActionCreated, | ||
| childOldestFourAccountIDs, | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Builds an optimistic reportAction for the parent report when a task is created | ||
| * @param {String} taskReportID - Report ID of the task | ||
|
|
@@ -2549,6 +2592,7 @@ export { | |
| buildOptimisticTaskReportAction, | ||
| buildOptimisticAddCommentReportAction, | ||
| buildOptimisticTaskCommentReportAction, | ||
| updateOptimisticParentReportAction, | ||
| shouldReportBeInOptionList, | ||
| getChatByParticipants, | ||
| getChatByParticipantsByLoginList, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused why we are adding a commenter based on the
oldestFourAccountIDs. We want to check that they've never commented in the thread before changing this right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this case,
oldestFourAccountIDs.length < 4 and the user isn't already in list that mean this is the first time the user comment, so I think increasechildCommenterCountfor this case makes sense.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should still be extracted outside of the
<4section actually. With the code you have here, we will only increase thechildCommenterCountif there are less than 4. We need to increase that regardless of how many people have commented, if it is this user's first time commenting. Right?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stitesExpensify We update
childCommenterCountfor this case because we know for sure that it's the user's first comment. For the case,oldestFourAccountIDs.length === 4, in FE we don't know the user had commented before or not. So we dont't updatechildCommenterCount.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
childCommenterCountvalue isn't that important in frontend as long as it meets> 0.Only used here:
App/src/pages/home/report/ReportActionItem.js
Line 339 in 138a41c