-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Sort reportActions by created instead of sequenceNumber #12626
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
30 commits
Select commit
Hold shift + click to select a range
8e06636
Implement sortReportActions function
roryabraham 117732a
Move sortReportActions to the top of ReportActionsUtils
roryabraham e1ac5b2
Preemptively re-implement getMostRecentIOUReportActionID
roryabraham 698555d
Merge branch 'Rory-MostRecentIOUReportActionID' into Rory-SortReportA…
roryabraham a20d183
Merge branch 'Rory-SequenceNumReportActionID' into Rory-SortReportAct…
roryabraham f7652b7
use sortReportActions to sort view
roryabraham c023645
Fix typo and some outdated item.action references
roryabraham ec49005
Fix typo and add FIXME for created
roryabraham 60db445
Merge branch 'main' into Rory-SortReportActionsByCreated
roryabraham afa1665
Merge branch 'main' into Rory-SortReportActionsByCreated
roryabraham 02a3d34
Remove outdated FIXME
roryabraham c8f36fb
Update a few new usages of sortBy with sequenceNumber
roryabraham 4cc45c4
Fix a few bugs from bad merge
roryabraham 5885686
Reverse sorting order in ReportActionsView for inverted FlatList
roryabraham 878b260
Implement faster inverted sorting order
roryabraham 78e5342
Fix variable naming
roryabraham d7b94a8
Remove outdated comment
roryabraham 6d877b3
Merge branch 'main' into Rory-SortReportActionsByCreated
roryabraham 54e0423
Remove actionName from sorting criteria and tests
roryabraham f31d037
Address review comments
roryabraham 90b18f9
Rename shouldInvertSortingOrder to shouldSortInDescendingOrder
roryabraham 0deab40
Rename sortReportActions to getSortedReportActions
roryabraham 007c5b8
Merge branch 'main' into Rory-SortReportActionsByCreated
roryabraham f6bca7c
Move function back to where it was to reduce diff
roryabraham 07e5fab
Add filtering back to reportActions
roryabraham 3f78a8c
Filter out any unsupported action types
roryabraham 21bac92
Extract filter function to ReportActionsUtils
roryabraham 0f826a7
Add tests for filter function
roryabraham 9db4179
Fix automated test
roryabraham 9e876e8
Simplify boolean
roryabraham 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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| import CONST from '../../src/CONST'; | ||
| import * as ReportActionsUtils from '../../src/libs/ReportActionsUtils'; | ||
|
|
||
| describe('ReportActionsUtils', () => { | ||
| describe('getSortedReportActions', () => { | ||
| const cases = [ | ||
| [ | ||
| [ | ||
| // This is the highest created timestamp, so should appear last | ||
| { | ||
| created: '2022-11-09 22:27:01.825', | ||
| reportActionID: '8401445780099176', | ||
| }, | ||
| { | ||
| created: '2022-11-09 22:27:01.600', | ||
| reportActionID: '6401435781022176', | ||
| }, | ||
|
|
||
| // These reportActions were created in the same millisecond so should appear ordered by reportActionID | ||
| { | ||
| created: '2022-11-09 22:26:48.789', | ||
| reportActionID: '2962390724708756', | ||
| }, | ||
| { | ||
| created: '2022-11-09 22:26:48.789', | ||
| reportActionID: '1609646094152486', | ||
| }, | ||
| { | ||
| created: '2022-11-09 22:26:48.789', | ||
| reportActionID: '1661970171066218', | ||
| }, | ||
| ], | ||
| [ | ||
| { | ||
| created: '2022-11-09 22:26:48.789', | ||
| reportActionID: '1609646094152486', | ||
| }, | ||
| { | ||
| created: '2022-11-09 22:26:48.789', | ||
| reportActionID: '1661970171066218', | ||
| }, | ||
| { | ||
| created: '2022-11-09 22:26:48.789', | ||
| reportActionID: '2962390724708756', | ||
| }, | ||
| { | ||
| created: '2022-11-09 22:27:01.600', | ||
| reportActionID: '6401435781022176', | ||
| }, | ||
| { | ||
| created: '2022-11-09 22:27:01.825', | ||
| reportActionID: '8401445780099176', | ||
| }, | ||
| ], | ||
| ], | ||
| ]; | ||
|
|
||
| test.each(cases)('sorts by created, then actionName, then reportActionID', (input, expectedOutput) => { | ||
| const result = ReportActionsUtils.getSortedReportActions(input); | ||
| expect(result).toStrictEqual(expectedOutput); | ||
| }); | ||
|
|
||
| test.each(cases)('in descending order', (input, expectedOutput) => { | ||
| const result = ReportActionsUtils.getSortedReportActions(input, true); | ||
| expect(result).toStrictEqual(expectedOutput.reverse()); | ||
| }); | ||
| }); | ||
|
|
||
| describe('filterReportActionsForDisplay', () => { | ||
| it('should filter out non-whitelisted actions', () => { | ||
| const input = [ | ||
| { | ||
| actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, | ||
| message: [{html: 'Hello world'}], | ||
| }, | ||
| { | ||
| actionName: CONST.REPORT.ACTIONS.TYPE.CLOSED, | ||
| message: [{html: 'Hello world'}], | ||
| }, | ||
| { | ||
| actionName: CONST.REPORT.ACTIONS.TYPE.CREATED, | ||
| message: [{html: 'Hello world'}], | ||
| }, | ||
| { | ||
| actionName: CONST.REPORT.ACTIONS.TYPE.IOU, | ||
| message: [{html: 'Hello world'}], | ||
| }, | ||
| { | ||
| actionName: CONST.REPORT.ACTIONS.TYPE.RENAMED, | ||
| message: [{html: 'Hello world'}], | ||
| }, | ||
| { | ||
| actionName: 'REIMBURSED', | ||
| message: [{html: 'Hello world'}], | ||
| }, | ||
| ]; | ||
| const result = ReportActionsUtils.filterReportActionsForDisplay(input); | ||
| input.pop(); | ||
| expect(result).toStrictEqual(input); | ||
| }); | ||
|
|
||
| it('should filter out deleted, non-pending comments', () => { | ||
| const input = [ | ||
| { | ||
| actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, | ||
| message: [{html: 'Hello world'}], | ||
| }, | ||
| { | ||
| actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, | ||
| message: [{html: ''}], | ||
| pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, | ||
| }, | ||
| { | ||
| actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, | ||
| message: [{html: ''}], | ||
| }, | ||
| ]; | ||
| const result = ReportActionsUtils.filterReportActionsForDisplay(input); | ||
| input.pop(); | ||
| expect(result).toStrictEqual(input); | ||
| }); | ||
| }); | ||
| }); |
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.
indexisn't needed anymore? I see it used inrenderItembut maybe the updateitem: reportAction,takes care of this? Just curiousThere 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.
Yeah, this isn't needed anymore. The
indexyou see inrenderItemcomes from React Native itself.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.
Thanks for the tip