-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Improvement: Sidebar Links Performance #26447
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
Changes from 21 commits
d5c7dd9
d0f687c
33017cf
3ac7d3c
497db51
de864d3
ed8e76c
79e40b8
48ab69a
67dbbd9
cad9c3f
fbc5fa2
bcb89cd
46563f0
1636050
9199e0c
782e43e
ca8a7cc
06080a4
2e51898
22da8de
42fff4a
f6efb26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/* eslint-disable rulesdir/prefer-underscore-method */ | ||
import lodashGet from 'lodash/get'; | ||
import _ from 'underscore'; | ||
import lodashMerge from 'lodash/merge'; | ||
import {max, parseISO, isEqual} from 'date-fns'; | ||
import lodashFindLast from 'lodash/findLast'; | ||
import Onyx from 'react-native-onyx'; | ||
import moment from 'moment'; | ||
import * as CollectionUtils from './CollectionUtils'; | ||
import CONST from '../CONST'; | ||
import ONYXKEYS from '../ONYXKEYS'; | ||
|
@@ -331,11 +331,7 @@ function shouldReportActionBeVisible(reportAction, key) { | |
} | ||
|
||
// Filter out any unsupported reportAction types | ||
if ( | ||
!_.has(CONST.REPORT.ACTIONS.TYPE, reportAction.actionName) && | ||
!_.contains(_.values(CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG), reportAction.actionName) && | ||
!_.contains(_.values(CONST.REPORT.ACTIONS.TYPE.TASK), reportAction.actionName) | ||
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. It seems we have accidentally removed this last condition as well. 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. This "TYPE.TASK" doesn't exist anymore, thats why I removed it 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. Oh, interesting. @mountiny We should double-check this. It may be possible that we forget to refactor this condition which could lead to further issues. 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. This is fine, I think it just go split up to |
||
) { | ||
if (!Object.values(CONST.REPORT.ACTIONS.TYPE).includes(reportAction.actionName) && !Object.values(CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG).includes(reportAction.actionName)) { | ||
return false; | ||
} | ||
|
||
|
@@ -350,7 +346,7 @@ function shouldReportActionBeVisible(reportAction, key) { | |
|
||
// All other actions are displayed except thread parents, deleted, or non-pending actions | ||
const isDeleted = isDeletedAction(reportAction); | ||
const isPending = !_.isEmpty(reportAction.pendingAction); | ||
const isPending = !!reportAction.pendingAction; | ||
return !isDeleted || isPending || isDeletedParentAction(reportAction); | ||
} | ||
|
||
|
@@ -379,14 +375,24 @@ function shouldReportActionBeVisibleAsLastAction(reportAction) { | |
* @return {Object} | ||
*/ | ||
function getLastVisibleAction(reportID, actionsToMerge = {}) { | ||
const actions = _.toArray(lodashMerge({}, allReportActions[reportID], actionsToMerge)); | ||
const visibleActions = _.filter(actions, (action) => shouldReportActionBeVisibleAsLastAction(action)); | ||
const updatedActionsToMerge = {}; | ||
if (actionsToMerge && Object.keys(actionsToMerge).length !== 0) { | ||
Object.keys(actionsToMerge).forEach( | ||
(actionToMergeID) => (updatedActionsToMerge[actionToMergeID] = {...allReportActions[reportID][actionToMergeID], ...actionsToMerge[actionToMergeID]}), | ||
); | ||
} | ||
const actions = Object.values({ | ||
...allReportActions[reportID], | ||
...updatedActionsToMerge, | ||
}); | ||
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. |
||
const visibleActions = actions.filter((action) => shouldReportActionBeVisibleAsLastAction(action)); | ||
waterim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (_.isEmpty(visibleActions)) { | ||
if (visibleActions.length === 0) { | ||
return {}; | ||
} | ||
|
||
return _.max(visibleActions, (action) => moment.utc(action.created).valueOf()); | ||
const maxDate = max(visibleActions.map((action) => parseISO(action.created))); | ||
const maxAction = visibleActions.find((action) => isEqual(parseISO(action.created), maxDate)); | ||
return maxAction; | ||
} | ||
|
||
/** | ||
|
waterim marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.