Skip to content
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

Merged
merged 12 commits into from
Dec 1, 2020
Binary file added assets/images/icon-pencil.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/pages/home/sidebar/ChatLinkRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import styles from '../../../styles/StyleSheet';
import ChatSwitcherOptionPropTypes from './ChatSwitcherOptionPropTypes';
import ROUTES from '../../../ROUTES';
import pencilIcon from '../../../../assets/images/icon-pencil.png';
import PressableLink from '../../../components/PressableLink';

const propTypes = {
Expand Down Expand Up @@ -124,6 +125,13 @@ const ChatLinkRow = ({
</TouchableOpacity>
</View>
)}
{option.hasDraftComment && (
<Image
style={[styles.LHNPencilIcon]}
resizeMode="contain"
source={pencilIcon}
/>
)}
</View>
);
};
Expand Down
22 changes: 19 additions & 3 deletions src/pages/home/sidebar/SidebarLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

This comment was marked as resolved.

This comment was marked as resolved.

comments: PropTypes.objectOf(PropTypes.string),

isChatSwitcherActive: PropTypes.bool,

// List of users' personal details
Expand All @@ -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, [
Expand All @@ -58,10 +64,16 @@ const SidebarLinks = (props) => {
'desc',
'asc'
]);
function hasComment(reportID) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing method docs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still missing method docs :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where? They are there!

Copy link
Contributor

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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}
Expand All @@ -123,6 +136,9 @@ export default compose(
reports: {
key: ONYXKEYS.COLLECTION.REPORT,
},
comments: {
key: ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT,
},
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS,
},
Expand Down
5 changes: 5 additions & 0 deletions src/styles/StyleSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,11 @@ const styles = {
width: 18,
},

LHNPencilIcon: {
height: 16,
width: 16,
},

attachmentCloseIcon: {
height: 20,
width: 20,
Expand Down