-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fixed LHN Ordering #35907
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
Fixed LHN Ordering #35907
Changes from 9 commits
9b040c5
6333dcd
87826ab
06f5775
f556253
f8ab7cc
90343b9
6b19fd2
c61adb1
cf3147f
6649bb9
40e7a05
89a56b2
102bbda
1eca3e1
1314854
4e35908
e15075f
651e372
70ef3fc
91cea78
e2f769a
8495e60
29216c2
888195b
f14090e
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ function OptionRowLHNData({ | |
lastReportActionTransaction = {}, | ||
transactionViolations, | ||
canUseViolations, | ||
reportErrors, | ||
...propsToForward | ||
}: OptionRowLHNDataProps) { | ||
const reportID = propsToForward.reportID; | ||
|
@@ -40,11 +41,11 @@ function OptionRowLHNData({ | |
// Note: ideally we'd have this as a dependent selector in onyx! | ||
const item = SidebarUtils.getOptionData({ | ||
report: fullReport, | ||
reportActions, | ||
personalDetails, | ||
preferredLocale: preferredLocale ?? CONST.LOCALES.DEFAULT, | ||
policy, | ||
parentReportAction, | ||
reportErrors, | ||
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 not added to the dependencies of 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.
parent:
and not sure about |
||
hasViolations: !!hasViolations, | ||
}); | ||
if (deepEqual(item, optionItemRef.current)) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import useLocalize from '@hooks/useLocalize'; | |
import usePrevious from '@hooks/usePrevious'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import compose from '@libs/compose'; | ||
import * as OptionsListUtils from '@libs/OptionsListUtils'; | ||
import {getPolicyMembersByIdWithoutCurrentUser} from '@libs/PolicyUtils'; | ||
import * as ReportUtils from '@libs/ReportUtils'; | ||
import SidebarUtils from '@libs/SidebarUtils'; | ||
|
@@ -139,6 +140,23 @@ function SidebarLinksData({ | |
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
useEffect(() => Policy.openWorkspace(activeWorkspaceID, policyMemberAccountIDs), [activeWorkspaceID]); | ||
|
||
const reportsWithErrorsIds = useMemo(() => { | ||
shubham1206agra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const reportKeys = _.keys(allReportActions); | ||
shubham1206agra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return _.reduce( | ||
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. Just a though, having 2 reduces, one nested the other, won't make this function O(n*m).
and then later in the reduce you act as normally?? not sure if the code will work just guessing and code it here on the fly :) 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. I have tried to do some optimization on this. Can you see this again? |
||
reportKeys, | ||
(errorsMap, reportKey) => { | ||
const report = chatReports[reportKey.replace('reportActions_', 'report_')]; | ||
const allReportsActions = _.reduce(allReportActions[reportKey], (acc, reportAction) => ({...acc, [reportAction.reportActionID]: reportAction}), {}); | ||
const errors = OptionsListUtils.getAllReportErrors(report, allReportsActions) || {}; | ||
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. I think we should pass the violations to 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 should re-render as transactionViolations changes, which is a dependency of memo. 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. But it is not a dependency of 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. @youssef-lr I think this is not needed. We are already subscribing to the violation collection, and it should re-render whenever any of the violations are updated. 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. While yes the page will re-render, the 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. @shubham1206agra bump, can we pass the transactions to 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. Apologies for the confusion, @fedirjh I disagree. Prior to the PR we weren’t pinning RBR reports, now that we’re memoized them, they are not subscribing to changes in the transaction. 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. @shubham1206agra @fedirjh what's the latest here? 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. We are awaiting @shubham1206agra to implement the changes. 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. @fedirjh Can you retest this now? |
||
if (_.size(errors) === 0) { | ||
return errorsMap; | ||
} | ||
return {...errorsMap, [reportKey.replace('reportActions_', '')]: OptionsListUtils.getAllReportErrors(report, allReportsActions) || {}}; | ||
shubham1206agra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
{}, | ||
); | ||
}, [allReportActions, chatReports]); | ||
|
||
const reportIDsRef = useRef(null); | ||
const isLoading = isLoadingApp; | ||
const optionListItems = useMemo(() => { | ||
|
@@ -152,6 +170,7 @@ function SidebarLinksData({ | |
transactionViolations, | ||
activeWorkspaceID, | ||
policyMemberAccountIDs, | ||
reportsWithErrorsIds, | ||
shubham1206agra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
|
||
if (deepEqual(reportIDsRef.current, reportIDs)) { | ||
|
@@ -165,7 +184,20 @@ function SidebarLinksData({ | |
reportIDsRef.current = reportIDs; | ||
} | ||
return reportIDsRef.current || []; | ||
}, [chatReports, betas, policies, priorityMode, allReportActions, transactionViolations, activeWorkspaceID, policyMemberAccountIDs, isLoading, network.isOffline, prevPriorityMode]); | ||
}, [ | ||
chatReports, | ||
betas, | ||
policies, | ||
priorityMode, | ||
allReportActions, | ||
transactionViolations, | ||
activeWorkspaceID, | ||
policyMemberAccountIDs, | ||
reportsWithErrorsIds, | ||
shubham1206agra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
isLoading, | ||
network.isOffline, | ||
prevPriorityMode, | ||
]); | ||
|
||
// We need to make sure the current report is in the list of reports, but we do not want | ||
// to have to re-generate the list every time the currentReportID changes. To do that | ||
|
@@ -184,10 +216,23 @@ function SidebarLinksData({ | |
transactionViolations, | ||
activeWorkspaceID, | ||
policyMemberAccountIDs, | ||
reportsWithErrorsIds, | ||
shubham1206agra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
} | ||
return optionListItems; | ||
}, [currentReportID, optionListItems, chatReports, betas, policies, priorityMode, allReportActions, transactionViolations, activeWorkspaceID, policyMemberAccountIDs]); | ||
}, [ | ||
currentReportID, | ||
optionListItems, | ||
chatReports, | ||
betas, | ||
policies, | ||
priorityMode, | ||
allReportActions, | ||
transactionViolations, | ||
activeWorkspaceID, | ||
policyMemberAccountIDs, | ||
reportsWithErrorsIds, | ||
shubham1206agra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
]); | ||
|
||
const currentReportIDRef = useRef(currentReportID); | ||
currentReportIDRef.current = currentReportID; | ||
|
@@ -209,6 +254,7 @@ function SidebarLinksData({ | |
isLoading={isLoading} | ||
optionListItems={optionListItemsWithCurrentReport} | ||
activeWorkspaceID={activeWorkspaceID} | ||
reportsWithErrorsIds={reportsWithErrorsIds} | ||
shubham1206agra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/> | ||
</View> | ||
); | ||
|
@@ -232,6 +278,7 @@ const chatReportSelector = (report) => | |
isPinned: report.isPinned, | ||
isHidden: report.isHidden, | ||
notificationPreference: report.notificationPreference, | ||
errors: report.errors, | ||
errorFields: { | ||
addWorkspaceRoom: report.errorFields && report.errorFields.addWorkspaceRoom, | ||
}, | ||
|
@@ -253,6 +300,9 @@ const chatReportSelector = (report) => | |
reportName: report.reportName, | ||
policyName: report.policyName, | ||
oldPolicyName: report.oldPolicyName, | ||
isPolicyExpenseChat: report.isPolicyExpenseChat, | ||
isOwnPolicyExpenseChat: report.isOwnPolicyExpenseChat, | ||
isCancelledIOU: report.isCancelledIOU, | ||
// Other less obvious properites considered for sorting: | ||
ownerAccountID: report.ownerAccountID, | ||
currency: report.currency, | ||
|
@@ -271,14 +321,15 @@ const chatReportSelector = (report) => | |
const reportActionsSelector = (reportActions) => | ||
reportActions && | ||
lodashMap(reportActions, (reportAction) => { | ||
const {reportActionID, parentReportActionID, actionName, errors = []} = reportAction; | ||
const {reportActionID, parentReportActionID, actionName, originalMessage, errors = []} = reportAction; | ||
const decision = lodashGet(reportAction, 'message[0].moderationDecision.decision'); | ||
|
||
return { | ||
reportActionID, | ||
parentReportActionID, | ||
actionName, | ||
errors, | ||
originalMessage, | ||
message: [ | ||
{ | ||
moderationDecision: {decision}, | ||
|
Uh oh!
There was an error while loading. Please reload this page.