-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Improve the readability and maintainability of the code which groups and sorts the reports in the sidebar #12558
Changes from 12 commits
94f978a
291cf65
9dedc71
5cad556
5806f58
863be99
a961129
945afdf
0c4b705
85c6dc1
0c09266
be6ebbf
1495687
305eb3a
f24a207
dc9bc97
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 | ||||
---|---|---|---|---|---|---|
|
@@ -967,7 +967,6 @@ function isUnread(report) { | |||||
* @param {Object} iouReports | ||||||
* @returns {boolean} | ||||||
*/ | ||||||
|
||||||
function hasOutstandingIOU(report, currentUserLogin, iouReports) { | ||||||
if (!report || !report.iouReportID || _.isUndefined(report.hasOutstandingIOU)) { | ||||||
return false; | ||||||
|
@@ -985,6 +984,39 @@ function hasOutstandingIOU(report, currentUserLogin, iouReports) { | |||||
return report.hasOutstandingIOU; | ||||||
} | ||||||
|
||||||
/** | ||||||
* @param {Object} report | ||||||
* @param {String} report.iouReportID | ||||||
* @param {Object} iouReports | ||||||
* @returns {null|Number} | ||||||
*/ | ||||||
function getIOUTotal(report, iouReports) { | ||||||
if (report.hasOutstandingIOU) { | ||||||
const iouReport = (iouReports && iouReports[`${ONYXKEYS.COLLECTION.REPORT_IOUS}${report.iouReportID}`]) || null; | ||||||
if (iouReport) { | ||||||
return iouReport.total; | ||||||
} | ||||||
} | ||||||
return null; | ||||||
} | ||||||
|
||||||
/** | ||||||
* @param {Object} report | ||||||
* @param {String} report.iouReportID | ||||||
* @param {String} currentUserLogin | ||||||
* @param {Object} iouReports | ||||||
* @returns {null|Boolean} | ||||||
*/ | ||||||
function isIOUOwnedByCurrentUser(report, currentUserLogin, iouReports) { | ||||||
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. NAB but we can lose the
Suggested change
|
||||||
if (report.hasOutstandingIOU) { | ||||||
const iouReport = (iouReports && iouReports[`${ONYXKEYS.COLLECTION.REPORT_IOUS}${report.iouReportID}`]) || null; | ||||||
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. nab, short circuit to |
||||||
if (iouReport) { | ||||||
return iouReport.ownerEmail === currentUserLogin; | ||||||
} | ||||||
} | ||||||
return null; | ||||||
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. Could we return |
||||||
} | ||||||
|
||||||
/** | ||||||
* Takes several pieces of data from Onyx and evaluates if a report should be shown in the option list (either when searching | ||||||
* for reports or the reports shown in the LHN). | ||||||
|
@@ -1098,6 +1130,8 @@ export { | |||||
hasExpensifyEmails, | ||||||
hasExpensifyGuidesEmails, | ||||||
hasOutstandingIOU, | ||||||
isIOUOwnedByCurrentUser, | ||||||
getIOUTotal, | ||||||
canShowReportRecipientLocalTime, | ||||||
formatReportLastMessageText, | ||||||
chatIncludesConcierge, | ||||||
|
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.
Same here.