From b1e3c736991cc63d15fea2dcb78e421a8be4f2e8 Mon Sep 17 00:00:00 2001 From: Santhoshkumar Sellavel Date: Fri, 25 Feb 2022 00:43:25 +0530 Subject: [PATCH 1/2] Remove timezone restriction to show time in chat --- src/libs/reportUtils.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/reportUtils.js b/src/libs/reportUtils.js index 509275bb420b..6a93691d01c7 100644 --- a/src/libs/reportUtils.js +++ b/src/libs/reportUtils.js @@ -2,7 +2,6 @@ import _ from 'underscore'; import Str from 'expensify-common/lib/str'; import lodashGet from 'lodash/get'; import Onyx from 'react-native-onyx'; -import moment from 'moment'; import ONYXKEYS from '../ONYXKEYS'; import CONST from '../CONST'; @@ -226,8 +225,7 @@ function canShowReportRecipientLocalTime(personalDetails, myPersonalDetails, rep && reportRecipient && reportRecipientTimezone && currentUserTimezone.selected - && reportRecipientTimezone.selected - && moment().tz(currentUserTimezone.selected).utcOffset() !== moment().tz(reportRecipientTimezone.selected).utcOffset(); + && reportRecipientTimezone.selected; } /** From 149197ebfa3b93d61d531effa23d36e69ddb5c15 Mon Sep 17 00:00:00 2001 From: Santhoshkumar Sellavel Date: Fri, 25 Feb 2022 19:59:12 +0530 Subject: [PATCH 2/2] Removed unused code --- src/libs/reportUtils.js | 5 +---- src/pages/home/report/ReportActionCompose.js | 12 ++---------- src/pages/home/report/ReportActionsView.js | 10 +--------- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/libs/reportUtils.js b/src/libs/reportUtils.js index 6a93691d01c7..6602990db090 100644 --- a/src/libs/reportUtils.js +++ b/src/libs/reportUtils.js @@ -210,21 +210,18 @@ function hasExpensifyEmails(emails) { /** * Whether the time row should be shown for a report. * @param {Array} personalDetails - * @param {Object} myPersonalDetails * @param {Object} report * @return {Boolean} */ -function canShowReportRecipientLocalTime(personalDetails, myPersonalDetails, report) { +function canShowReportRecipientLocalTime(personalDetails, report) { const reportParticipants = lodashGet(report, 'participants', []); const hasMultipleParticipants = reportParticipants.length > 1; const reportRecipient = personalDetails[reportParticipants[0]]; - const currentUserTimezone = lodashGet(myPersonalDetails, 'timezone', CONST.DEFAULT_TIME_ZONE); const reportRecipientTimezone = lodashGet(reportRecipient, 'timezone', CONST.DEFAULT_TIME_ZONE); return !hasExpensifyEmails(reportParticipants) && !hasMultipleParticipants && reportRecipient && reportRecipientTimezone - && currentUserTimezone.selected && reportRecipientTimezone.selected; } diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index c5defe261608..f62ab759dbdf 100755 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -36,7 +36,6 @@ import * as ReportUtils from '../../../libs/reportUtils'; import ReportActionComposeFocusManager from '../../../libs/ReportActionComposeFocusManager'; import Text from '../../../components/Text'; import {participantPropTypes} from '../sidebar/optionPropTypes'; -import currentUserPersonalDetailsPropsTypes from '../../settings/Profile/currentUserPersonalDetailsPropsTypes'; import ParticipantLocalTime from './ParticipantLocalTime'; import {withNetwork, withPersonalDetails} from '../../../components/OnyxProvider'; import DateUtils from '../../../libs/DateUtils'; @@ -64,9 +63,6 @@ const propTypes = { isVisible: PropTypes.bool, }), - /** The personal details of the person who is logged in */ - myPersonalDetails: PropTypes.shape(currentUserPersonalDetailsPropsTypes), - /** Personal details of all the users */ personalDetails: PropTypes.objectOf(participantPropTypes), @@ -112,7 +108,6 @@ const defaultProps = { network: {isOffline: false}, blockedFromConcierge: {}, personalDetails: {}, - myPersonalDetails: {}, }; class ReportActionCompose extends React.Component { @@ -391,7 +386,7 @@ class ReportActionCompose extends React.Component { render() { // Waiting until ONYX variables are loaded before displaying the component - if (_.isEmpty(this.props.personalDetails) || _.isEmpty(this.props.myPersonalDetails)) { + if (_.isEmpty(this.props.personalDetails)) { return null; } @@ -399,7 +394,7 @@ class ReportActionCompose extends React.Component { const hasMultipleParticipants = reportParticipants.length > 1; const hasExcludedIOUEmails = lodashIntersection(reportParticipants, CONST.EXPENSIFY_EMAILS).length > 0; const reportRecipient = this.props.personalDetails[reportParticipants[0]]; - const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(this.props.personalDetails, this.props.myPersonalDetails, this.props.report); + const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(this.props.personalDetails, this.props.report); // Prevents focusing and showing the keyboard while the drawer is covering the chat. const isComposeDisabled = this.props.isDrawerOpen && this.props.isSmallScreenWidth; @@ -632,9 +627,6 @@ export default compose( modal: { key: ONYXKEYS.MODAL, }, - myPersonalDetails: { - key: ONYXKEYS.MY_PERSONAL_DETAILS, - }, blockedFromConcierge: { key: ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE, }, diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index 0e8e924b02d0..bf463795d9d8 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -36,7 +36,6 @@ import Performance from '../../../libs/Performance'; import * as ReportUtils from '../../../libs/reportUtils'; import ONYXKEYS from '../../../ONYXKEYS'; import {withPersonalDetails} from '../../../components/OnyxProvider'; -import currentUserPersonalDetailsPropsTypes from '../../settings/Profile/currentUserPersonalDetailsPropsTypes'; import {participantPropTypes} from '../sidebar/optionPropTypes'; import EmojiPicker from '../../../components/EmojiPicker'; import * as EmojiPickerAction from '../../../libs/actions/EmojiPickerAction'; @@ -74,9 +73,6 @@ const propTypes = { /** Are we loading more report actions? */ isLoadingReportActions: PropTypes.bool, - /** The personal details of the person who is logged in */ - myPersonalDetails: PropTypes.shape(currentUserPersonalDetailsPropsTypes), - /** Personal details of all the users */ personalDetails: PropTypes.objectOf(participantPropTypes), @@ -95,7 +91,6 @@ const defaultProps = { session: {}, isLoadingReportActions: false, personalDetails: {}, - myPersonalDetails: {}, }; class ReportActionsView extends React.Component { @@ -547,7 +542,7 @@ class ReportActionsView extends React.Component { // Native mobile does not render updates flatlist the changes even though component did update called. // To notify there something changes we can use extraData prop to flatlist const extraData = (!this.props.isDrawerOpen && this.props.isSmallScreenWidth) ? this.props.report.newMarkerSequenceNumber : undefined; - const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(this.props.personalDetails, this.props.myPersonalDetails, this.props.report); + const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(this.props.personalDetails, this.props.report); return ( <> @@ -600,8 +595,5 @@ export default compose( key: ONYXKEYS.IS_LOADING_REPORT_ACTIONS, initWithStoredValues: false, }, - myPersonalDetails: { - key: ONYXKEYS.MY_PERSONAL_DETAILS, - }, }), )(ReportActionsView);