Skip to content
Merged
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.
12 changes: 10 additions & 2 deletions src/pages/home/sidebar/ChatLinkRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import styles, {colors} 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 @@ -87,9 +88,9 @@ const ChatLinkRow = ({
)
}
<View style={[styles.flex1]}>
{option.text === option.alternateText ? (
{(option.text === option.alternateText || option.alternateText.length === 0) ? (
<Text style={[styles.chatSwitcherDisplayName, textUnreadStyle]} numberOfLines={1}>
{option.alternateText}
{option.text}
</Text>
) : (
<>
Expand Down Expand Up @@ -122,6 +123,13 @@ const ChatLinkRow = ({
</TouchableOpacity>
</View>
)}
{option.hasDraftComment && (
<Image
style={[styles.LHNPencilIcon]}
resizeMode="contain"
source={pencilIcon}
/>
)}
</View>
);
};
Expand Down
29 changes: 26 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 @@ -59,9 +65,22 @@ const SidebarLinks = (props) => {
'asc'
]);

// 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));
/**
* Check if the report has a draft comment
*
* @param {number} reportID
* @returns {boolean}
*/
function hasComment(reportID) {

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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, 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 +121,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 +143,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