-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Keep chats with draft comments in the LHN #781
Changes from 9 commits
46e7f62
9f21436
b8784fb
6fb89fe
5e463dc
f0b3531
996600d
ee45cb4
34f5d48
4859ab6
398b5eb
974e2e3
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 |
---|---|---|
|
@@ -34,6 +34,9 @@ const propTypes = { | |
unreadActionCount: PropTypes.number, | ||
})), | ||
|
||
// List of draft comments. We don't know the shape, since the keys include the report numbers | ||
comments: PropTypes.objectOf(PropTypes.string), | ||
|
||
isChatSwitcherActive: PropTypes.bool, | ||
|
||
// List of users' personal details | ||
|
@@ -43,12 +46,15 @@ const propTypes = { | |
displayName: PropTypes.string.isRequired, | ||
})), | ||
}; | ||
|
||
const defaultProps = { | ||
reports: {}, | ||
isChatSwitcherActive: false, | ||
comments: {}, | ||
personalDetails: {}, | ||
}; | ||
|
||
|
||
const SidebarLinks = (props) => { | ||
const reportIDInUrl = parseInt(props.match.params.reportID, 10); | ||
const sortedReports = lodashOrderby(props.reports, [ | ||
|
@@ -58,10 +64,16 @@ const SidebarLinks = (props) => { | |
'desc', | ||
'asc' | ||
]); | ||
function hasComment(reportID) { | ||
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. Missing method docs 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. Still missing method docs :D 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. Where? They are there! 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 wow, there they are. If you go to the "Conversation" tab in the PR and look at this conversation, it still shows the old code without the docs and that's what I was looking at. SOrry! |
||
const allComments = get(props.comments, `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`, ''); | ||
return allComments.length > 0; | ||
} | ||
|
||
// Filter the reports so that the only reports shown are pinned, unread, and the one matching the URL | ||
// eslint-disable-next-line max-len | ||
const reportsToDisplay = _.filter(sortedReports, report => (report.isPinned || (report.unreadActionCount > 0) || report.reportID === reportIDInUrl)); | ||
// Filter the reports so that the only reports shown are pinned, unread, have draft | ||
// comments (but are not the open one), and the one matching the URL | ||
const reportsToDisplay = _.filter(sortedReports, report => (report.isPinned || (report.unreadActionCount > 0) | ||
|| report.reportID === reportIDInUrl | ||
|| (report.reportID !== reportIDInUrl && hasComment(report.reportID)))); | ||
|
||
// Update styles to hide the report links if they should not be visible | ||
const sidebarLinksStyle = !props.isChatSwitcherActive | ||
|
@@ -102,6 +114,7 @@ const SidebarLinks = (props) => { | |
login: participantDetails ? participantDetails.login : '', | ||
reportID: report.reportID, | ||
isUnread: report.unreadActionCount > 0, | ||
hasDraftComment: report.reportID !== reportIDInUrl && hasComment(report.reportID) | ||
}} | ||
onSelectRow={props.onLinkClick} | ||
optionIsFocused={report.reportID === reportIDInUrl} | ||
|
@@ -123,6 +136,9 @@ export default compose( | |
reports: { | ||
key: ONYXKEYS.COLLECTION.REPORT, | ||
}, | ||
comments: { | ||
key: ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, | ||
}, | ||
personalDetails: { | ||
key: ONYXKEYS.PERSONAL_DETAILS, | ||
}, | ||
|
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
Sorry, something went wrong.