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

make avatar and welcome message pressable #8409

Merged
merged 9 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import * as Localize from './Localize';
import * as LocalePhoneNumber from './LocalePhoneNumber';
import * as Expensicons from '../components/Icon/Expensicons';
import md5 from './md5';
import Navigation from './Navigation/Navigation';
import ROUTES from '../ROUTES';

let sessionEmail;
Onyx.connect({
Expand Down Expand Up @@ -481,6 +483,24 @@ function getReportName(report, personalDetailsForParticipants = {}, policies = {
return _.map(displayNamesWithTooltips, ({displayName}) => displayName).join(', ');
}

/**
* Navigate to the details page of a given report
*
* @param {Object} report
* @param {Array} participants
*/
function navigateToDetailsPage(report, participants) {
if (isChatRoom(report) || isPolicyExpenseChat(report)) {
Navigation.navigate(ROUTES.getReportDetailsRoute(report.reportID));
return;
}
if (participants.length === 1) {
Navigation.navigate(ROUTES.getDetailsRoute(participants[0]));
return;
}
Navigation.navigate(ROUTES.getReportParticipantsRoute(report.reportID));
}

export {
getReportParticipantsTitle,
isReportMessageAttachment,
Expand All @@ -507,4 +527,5 @@ export {
getRoomWelcomeMessage,
getDisplayNamesWithTooltips,
getReportName,
navigateToDetailsPage,
};
15 changes: 1 addition & 14 deletions src/pages/home/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import * as Report from '../../libs/actions/Report';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../components/withWindowDimensions';
import MultipleAvatars from '../../components/MultipleAvatars';
import SubscriptAvatar from '../../components/SubscriptAvatar';
import Navigation from '../../libs/Navigation/Navigation';
import ROUTES from '../../ROUTES';
import DisplayNames from '../../components/DisplayNames';
import * as OptionsListUtils from '../../libs/OptionsListUtils';
import participantPropTypes from '../../components/participantPropTypes';
Expand All @@ -28,9 +26,6 @@ import Text from '../../components/Text';
import Tooltip from '../../components/Tooltip';

const propTypes = {
/** The ID of the report */
reportID: PropTypes.number.isRequired,

/** Toggles the navigationMenu open and closed */
onNavigationMenuButtonClicked: PropTypes.func.isRequired,

Expand Down Expand Up @@ -113,15 +108,7 @@ const HeaderView = (props) => {
]}
>
<Pressable
onPress={() => {
if (isChatRoom || isPolicyExpenseChat) {
return Navigation.navigate(ROUTES.getReportDetailsRoute(props.reportID));
}
if (participants.length === 1) {
return Navigation.navigate(ROUTES.getDetailsRoute(participants[0]));
}
Navigation.navigate(ROUTES.getReportParticipantsRoute(props.reportID));
}}
onPress={() => ReportUtils.navigateToDetailsPage(props.report, participants)}
style={[styles.flexRow, styles.alignItemsCenter, styles.flex1]}
>
{shouldShowSubscript ? (
Expand Down
18 changes: 1 addition & 17 deletions src/pages/home/report/ReportActionItemCreated.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import ReportWelcomeText from '../../../components/ReportWelcomeText';
import participantPropTypes from '../../../components/participantPropTypes';
import * as ReportUtils from '../../../libs/ReportUtils';
import styles from '../../../styles/styles';
import Navigation from '../../../libs/Navigation/Navigation';
import ROUTES from '../../../ROUTES';

const propTypes = {
/** The report currently being looked at */
Expand All @@ -20,9 +18,6 @@ const propTypes = {

/** Whether the user is not an admin of policyExpenseChat chat */
isOwnPolicyExpenseChat: PropTypes.bool,

/** ID of the report */
reportID: PropTypes.number,
}),

/** Personal details of all the users */
Expand All @@ -42,20 +37,9 @@ const defaultProps = {

const ReportActionItemCreated = (props) => {
const participants = lodashGet(props.report, 'participants', []);
const isChatRoom = ReportUtils.isChatRoom(props.report);
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(props.report);
const icons = ReportUtils.getIcons(props.report, props.personalDetails, props.policies);

function navigateToDetailsPage() {
if (isChatRoom || isPolicyExpenseChat) {
return Navigation.navigate(ROUTES.getReportDetailsRoute(props.report.reportID));
}
if (participants.length === 1) {
return Navigation.navigate(ROUTES.getDetailsRoute(participants[0]));
}
Navigation.navigate(ROUTES.getReportParticipantsRoute(props.report.reportID));
}

return (
<View style={[
styles.chatContent,
Expand All @@ -64,7 +48,7 @@ const ReportActionItemCreated = (props) => {
]}
>
<View style={[styles.justifyContentCenter, styles.alignItemsCenter, styles.flex1]}>
<Pressable onPress={navigateToDetailsPage}>
<Pressable onPress={() => ReportUtils.navigateToDetailsPage(props.report, participants)}>
<RoomHeaderAvatars
icons={icons}
shouldShowLargeAvatars={isPolicyExpenseChat}
Expand Down