From 0f58b1c818c0c81d578c812c1ef0a7ccaf8501a3 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Tue, 13 Jul 2021 13:58:56 -0700 Subject: [PATCH 1/9] Use trashcan icon when room is in closed state --- assets/images/avatars/deleted-room.svg | 13 +++++++++++ src/components/Avatar.js | 8 +++++-- src/components/MultipleAvatars.js | 13 +++++++++-- src/components/RoomAvatar.js | 30 ++++++++++++++++++++++++++ src/libs/OptionsListUtils.js | 3 ++- src/libs/actions/Report.js | 2 ++ src/libs/reportUtils.js | 14 ++++++++++++ src/pages/ReportDetailsPage.js | 3 ++- src/pages/home/HeaderView.js | 3 ++- src/pages/home/sidebar/OptionRow.js | 1 + 10 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 assets/images/avatars/deleted-room.svg create mode 100644 src/components/RoomAvatar.js diff --git a/assets/images/avatars/deleted-room.svg b/assets/images/avatars/deleted-room.svg new file mode 100644 index 0000000000000..a6b59c7b3f533 --- /dev/null +++ b/assets/images/avatars/deleted-room.svg @@ -0,0 +1,13 @@ + + + + + + + diff --git a/src/components/Avatar.js b/src/components/Avatar.js index 841900b2b1dd2..08268a36f27ea 100644 --- a/src/components/Avatar.js +++ b/src/components/Avatar.js @@ -2,7 +2,7 @@ import React, {PureComponent} from 'react'; import {Image, View, StyleSheet} from 'react-native'; import PropTypes from 'prop-types'; import styles from '../styles/styles'; -import RoomAvatar from '../../assets/images/avatars/room.svg'; +import RoomAvatar from './RoomAvatar'; const propTypes = { /** Url source for the avatar */ @@ -19,6 +19,9 @@ const propTypes = { /** Whether this avatar is for a default room */ isDefaultChatRoom: PropTypes.bool, + + /** Whether this avatar is for an archived default room */ + isArchivedRoom: PropTypes.bool, }; const defaultProps = { @@ -27,6 +30,7 @@ const defaultProps = { containerStyles: [], size: 'default', isDefaultChatRoom: false, + isArchivedRoom: false, }; class Avatar extends PureComponent { @@ -42,7 +46,7 @@ class Avatar extends PureComponent { return ( {this.props.isDefaultChatRoom - ? + ? : } ); diff --git a/src/components/MultipleAvatars.js b/src/components/MultipleAvatars.js index 079ac370928b4..99c4320a247f6 100644 --- a/src/components/MultipleAvatars.js +++ b/src/components/MultipleAvatars.js @@ -18,6 +18,9 @@ const propTypes = { /** Whether this avatar is for a default room */ isDefaultChatRoom: PropTypes.bool, + + /** Whether this avatar is for an archived room */ + isArchivedRoom: PropTypes.bool, }; const defaultProps = { @@ -25,10 +28,11 @@ const defaultProps = { size: 'default', secondAvatarStyle: [styles.secondAvatarHovered], isDefaultChatRoom: false, + isArchivedRoom: false, }; const MultipleAvatars = ({ - avatarImageURLs, size, secondAvatarStyle, isDefaultChatRoom, + avatarImageURLs, size, secondAvatarStyle, isDefaultChatRoom, isArchivedRoom }) => { const avatarContainerStyles = size === 'small' ? styles.emptyAvatarSmall : styles.emptyAvatar; const singleAvatarStyles = size === 'small' ? styles.singleAvatarSmall : styles.singleAvatar; @@ -44,7 +48,12 @@ const MultipleAvatars = ({ if (avatarImageURLs.length === 1) { return ( - + ); } diff --git a/src/components/RoomAvatar.js b/src/components/RoomAvatar.js new file mode 100644 index 0000000000000..47fde87aa71e4 --- /dev/null +++ b/src/components/RoomAvatar.js @@ -0,0 +1,30 @@ +import React, {PureComponent} from 'react'; +import PropTypes from 'prop-types'; +import ActiveRoomAvatar from '../../assets/images/avatars/room.svg'; +import DeletedRoomAvatar from '../../assets/images/avatars/deleted-room.svg'; + +const propTypes = { + /** Extra styles to pass to Image */ + avatarStyle: PropTypes.arrayOf(PropTypes.object), + + /** Whether the room this avatar is for is deleted or not */ + isArchived: PropTypes.bool, +}; + +const defaultProps = { + avatarStyle: [], + isArchived: false, +}; + +class RoomAvatar extends PureComponent { + render() { + return (this.props.isArchived + ? + : + ); + } +} + +RoomAvatar.defaultProps = defaultProps; +RoomAvatar.propTypes = propTypes; +export default RoomAvatar; diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 48c2918c61336..7e2dadd94bfa9 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -6,7 +6,7 @@ import lodashOrderBy from 'lodash/orderBy'; import Str from 'expensify-common/lib/str'; import ONYXKEYS from '../ONYXKEYS'; import CONST from '../CONST'; -import {getReportParticipantsTitle, isDefaultRoom, getDefaultRoomSubtitle} from './reportUtils'; +import {getReportParticipantsTitle, isDefaultRoom, getDefaultRoomSubtitle, isArchivedRoom} from './reportUtils'; import {translate} from './translate'; import Permissions from './Permissions'; import md5 from './md5'; @@ -227,6 +227,7 @@ function createOption(personalDetailList, report, draftComments, { hasOutstandingIOU, iouReportID: lodashGet(report, 'iouReportID'), isDefaultChatRoom, + isArchivedRoom: isArchivedRoom(report), }; } diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index ac7f8b6aa4b11..2c2bed6bc3673 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -195,6 +195,8 @@ function getSimplifiedReportObject(report) { lastActorEmail, hasOutstandingIOU: false, notificationPreference, + stateNum: report.stateNum, + statusNum: report.reportStatus, }; } diff --git a/src/libs/reportUtils.js b/src/libs/reportUtils.js index ff766380ab278..7a508ba7f3a46 100644 --- a/src/libs/reportUtils.js +++ b/src/libs/reportUtils.js @@ -123,6 +123,19 @@ function getDefaultRoomSubtitle(report, policiesMap) { ); } +/** + * Whether the provided report is an archived room + * @param {Object} report + * @returns {Boolean} + */ +function isArchivedRoom(report) { + if (!isDefaultRoom(report)) { + return false; + } + + return report.statusNum === 2 && report.stateNum === 2; +} + export { getReportParticipantsTitle, isReportMessageAttachment, @@ -132,4 +145,5 @@ export { sortReportsByLastVisited, isDefaultRoom, getDefaultRoomSubtitle, + isArchivedRoom, }; diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index 16327accd60a3..9b95e37ecec82 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -15,7 +15,7 @@ import HeaderWithCloseButton from '../components/HeaderWithCloseButton'; import styles from '../styles/styles'; import DisplayNames from '../components/DisplayNames'; import {getPersonalDetailsForLogins} from '../libs/OptionsListUtils'; -import {getDefaultRoomSubtitle, isDefaultRoom} from '../libs/reportUtils'; +import {getDefaultRoomSubtitle, isDefaultRoom, isArchivedRoom} from '../libs/reportUtils'; import {participantPropTypes} from './home/sidebar/optionPropTypes'; import Picker from '../components/Picker'; import {updateNotificationPreference} from '../libs/actions/Report'; @@ -128,6 +128,7 @@ class ReportDetailsPage extends Component { > { avatarImageURLs={props.report.icons} secondAvatarStyle={[styles.secondAvatarHovered]} isDefaultChatRoom={isDefaultChatRoom} + isArchivedRoom={isArchivedRoom(props.report)} /> ) } From 3188970b90a752a4d4a5ec955a1514a5ac9d0225 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Tue, 13 Jul 2021 14:36:58 -0700 Subject: [PATCH 2/9] Show deleted as part of report title when report is archived --- src/languages/en.js | 2 ++ src/languages/es.js | 2 ++ src/libs/actions/Report.js | 10 ++++++++-- src/libs/reportUtils.js | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index caefe148d9294..93c467a694275 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -30,6 +30,7 @@ export default { privacy: 'Privacy', privacyPolicy: 'Privacy Policy', delete: 'Delete', + deleted: 'Deleted', contacts: 'Contacts', recents: 'Recents', close: 'Close', @@ -107,6 +108,7 @@ export default { youAppearToBeOffline: 'You appear to be offline.', fileUploadFailed: 'Upload Failed. File is not supported.', localTime: ({user, time}) => `It's ${time} for ${user}`, + roomIsArchived: 'This chat room has been deleted', }, contextMenuItem: { copyToClipboard: 'Copy to Clipboard', diff --git a/src/languages/es.js b/src/languages/es.js index 42dd0cb674dd5..c84ebcc57cdb8 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -26,6 +26,7 @@ export default { and: 'y', details: 'Detalles', delete: 'Eliminar', + deleted: 'Eliminado', contacts: 'Contactos', recents: 'Recientes', close: 'Cerrar', @@ -102,6 +103,7 @@ export default { blockedFromConcierge: 'Comunicación no permitida', youAppearToBeOffline: 'Parece que estás desconectado.', localTime: ({user, time}) => `Son las ${time} para ${user}`, + roomIsArchived: 'Esta sala de chat ha sido eliminado', }, reportActionContextMenu: { copyToClipboard: 'Copiar al Portapapeles', diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 2c2bed6bc3673..80e64f355ae96 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -18,7 +18,7 @@ import Timing from './Timing'; import * as API from '../API'; import CONST from '../../CONST'; import Log from '../Log'; -import {isDefaultRoom, isReportMessageAttachment, sortReportsByLastVisited} from '../reportUtils'; +import {isArchivedRoom, isDefaultRoom, isReportMessageAttachment, sortReportsByLastVisited} from '../reportUtils'; import Timers from '../Timers'; import {dangerouslyGetReportActionsMaxSequenceNumber, isReportMissingActions} from './ReportActions'; import Growl from '../Growl'; @@ -131,7 +131,13 @@ function getParticipantEmailsFromReport({sharedReportList}) { */ function getChatReportName(fullReport, chatType) { if (isDefaultRoom({chatType})) { - return `#${fullReport.reportName}`; + return `#${fullReport.reportName}${(isArchivedRoom({ + chatType, + stateNum: fullReport.stateNum, + statusNum: fullReport.reportStatus, + }) + ? ` (${translateLocal('common.deleted')})` + : '')}`; } const {sharedReportList} = fullReport; diff --git a/src/libs/reportUtils.js b/src/libs/reportUtils.js index 7a508ba7f3a46..ba64cf2b5a6cd 100644 --- a/src/libs/reportUtils.js +++ b/src/libs/reportUtils.js @@ -126,6 +126,8 @@ function getDefaultRoomSubtitle(report, policiesMap) { /** * Whether the provided report is an archived room * @param {Object} report + * @param {Number} report.stateNum + * @param {Number} report.statusNum * @returns {Boolean} */ function isArchivedRoom(report) { From 6080340978c04959c2c90687a7d56172f1df6373 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Tue, 13 Jul 2021 15:28:47 -0700 Subject: [PATCH 3/9] Disable chat input when room is deleted --- src/languages/en.js | 2 +- src/languages/es.js | 4 +- src/pages/ReportDetailsPage.js | 63 +++++++++++--------- src/pages/home/report/ReportActionCompose.js | 37 +++++++++--- 4 files changed, 65 insertions(+), 41 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index 93c467a694275..7f89fc0af9ecd 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -30,7 +30,7 @@ export default { privacy: 'Privacy', privacyPolicy: 'Privacy Policy', delete: 'Delete', - deleted: 'Deleted', + deleted: 'deleted', contacts: 'Contacts', recents: 'Recents', close: 'Close', diff --git a/src/languages/es.js b/src/languages/es.js index c84ebcc57cdb8..6c3f00aec0dcf 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -26,7 +26,7 @@ export default { and: 'y', details: 'Detalles', delete: 'Eliminar', - deleted: 'Eliminado', + deleted: 'eliminado', contacts: 'Contactos', recents: 'Recientes', close: 'Cerrar', @@ -103,7 +103,7 @@ export default { blockedFromConcierge: 'Comunicación no permitida', youAppearToBeOffline: 'Parece que estás desconectado.', localTime: ({user, time}) => `Son las ${time} para ${user}`, - roomIsArchived: 'Esta sala de chat ha sido eliminado', + roomIsArchived: 'Esta sala de chat ha sido eliminada', }, reportActionContextMenu: { copyToClipboard: 'Copiar al Portapapeles', diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index 9b95e37ecec82..38229dc46bfb5 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -88,14 +88,15 @@ class ReportDetailsPage extends Component { }, }; - this.menuItems = [ - { - translationKey: 'reportDetailsPage.members', - icon: Users, - subtitle: props.report.participants.length, - action: () => { Navigation.navigate(ROUTES.getReportParticipantsRoute(props.report.reportID)); }, - }, - ]; + this.menuItems = isArchivedRoom(this.props.report) ? [] + : [ + { + translationKey: 'reportDetailsPage.members', + icon: Users, + subtitle: props.report.participants.length, + action: () => { Navigation.navigate(ROUTES.getReportParticipantsRoute(props.report.reportID)); }, + }, + ]; } render() { @@ -150,28 +151,32 @@ class ReportDetailsPage extends Component { - - - {this.props.translate('common.notifications')} - - - - - {this.props.translate('reportDetailsPage.notificationPreferencesDescription')} - - - { - updateNotificationPreference( - this.props.report.reportID, - notificationPreference, - ); - }} - items={Object.values(this.notificationPreferencesOptions)} - value={this.props.report.notificationPreference} - /> + {!isArchivedRoom(this.props.report) && ( + + + + {this.props.translate('common.notifications')} + + + + + {this.props.translate('reportDetailsPage.notificationPreferencesDescription')} + + + { + updateNotificationPreference( + this.props.report.reportID, + notificationPreference, + ); + }} + items={Object.values(this.notificationPreferencesOptions)} + value={this.props.report.notificationPreference} + /> + + - + )} {this.menuItems.map((item) => { const keyTitle = item.translationKey ? this.props.translate(item.translationKey) : item.title; diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index dc93d6a545d04..4564cba699aae 100755 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -50,7 +50,7 @@ import Navigation from '../../../libs/Navigation/Navigation'; import ROUTES from '../../../ROUTES'; import * as User from '../../../libs/actions/User'; import ReportActionPropTypes from './ReportActionPropTypes'; -import {canEditReportAction} from '../../../libs/reportUtils'; +import {canEditReportAction, isArchivedRoom} from '../../../libs/reportUtils'; import ReportActionComposeFocusManager from '../../../libs/ReportActionComposeFocusManager'; import Text from '../../../components/Text'; import {participantPropTypes} from '../sidebar/optionPropTypes'; @@ -147,6 +147,7 @@ class ReportActionCompose extends React.Component { this.emojiPopoverAnchor = null; this.emojiSearchInput = null; this.setTextInputRef = this.setTextInputRef.bind(this); + this.getInputPlaceholder = this.getInputPlaceholder.bind(this) this.state = { isFocused: this.shouldFocusInputOnScreenFocus, @@ -377,6 +378,26 @@ class ReportActionCompose extends React.Component { } } + /** + * Get the placeholder to display in the chat input. + * + * @return {String} + */ + getInputPlaceholder() { + if (isArchivedRoom(this.props.report)) { + return this.props.translate('reportActionCompose.roomIsArchived'); + } + + if (this.props.report.participants + && this.props.report.participants.includes(CONST.EMAIL.CONCIERGE) + && !_.isEmpty(this.props.blockedFromConcierge) + && User.isBlockedFromConcierge(this.props.blockedFromConcierge.expiresAt)) { + return this.props.translate('reportActionCompose.blockedFromConcierge'); + } + + return this.props.translate('reportActionCompose.writeSomething'); + } + /** * Add a new comment to this chat * @@ -421,10 +442,8 @@ class ReportActionCompose extends React.Component { if (isConciergeChat && !_.isEmpty(this.props.blockedFromConcierge)) { isBlockedFromConcierge = User.isBlockedFromConcierge(this.props.blockedFromConcierge.expiresAt); } - - const inputPlaceholder = isBlockedFromConcierge - ? this.props.translate('reportActionCompose.blockedFromConcierge') - : this.props.translate('reportActionCompose.writeSomething'); + const inputPlaceholder = this.getInputPlaceholder(); + const isArchivedChatRoom = isArchivedRoom(this.props.report); return ( @@ -555,7 +574,7 @@ class ReportActionCompose extends React.Component { onPasteFile={file => displayFileInModal({file})} shouldClear={this.state.textInputShouldClear} onClear={() => this.setTextInputShouldClear(false)} - isDisabled={isComposeDisabled || isBlockedFromConcierge} + isDisabled={isComposeDisabled || isBlockedFromConcierge || isArchivedChatRoom} selection={this.state.selection} onSelectionChange={this.onSelectionChange} /> @@ -594,7 +613,7 @@ class ReportActionCompose extends React.Component { ref={el => this.emojiPopoverAnchor = el} onLayout={this.measureEmojiPopoverAnchorPosition} onPress={this.showEmojiPicker} - disabled={isBlockedFromConcierge} + disabled={isBlockedFromConcierge || isArchivedChatRoom} > {({hovered, pressed}) => ( From 199afa1867c549e01e03b07a001bad1fcc058dbc Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Wed, 14 Jul 2021 15:38:58 -0700 Subject: [PATCH 4/9] JS Style --- src/components/MultipleAvatars.js | 2 +- src/libs/OptionsListUtils.js | 4 +- src/libs/actions/Report.js | 2 +- src/pages/home/report/ReportActionCompose.js | 42 ++++++++++---------- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/components/MultipleAvatars.js b/src/components/MultipleAvatars.js index 99c4320a247f6..518cf507a641a 100644 --- a/src/components/MultipleAvatars.js +++ b/src/components/MultipleAvatars.js @@ -32,7 +32,7 @@ const defaultProps = { }; const MultipleAvatars = ({ - avatarImageURLs, size, secondAvatarStyle, isDefaultChatRoom, isArchivedRoom + avatarImageURLs, size, secondAvatarStyle, isDefaultChatRoom, isArchivedRoom, }) => { const avatarContainerStyles = size === 'small' ? styles.emptyAvatarSmall : styles.emptyAvatar; const singleAvatarStyles = size === 'small' ? styles.singleAvatarSmall : styles.singleAvatar; diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 2b50709cf7678..d5630c99fa0fe 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -6,7 +6,9 @@ import lodashOrderBy from 'lodash/orderBy'; import Str from 'expensify-common/lib/str'; import ONYXKEYS from '../ONYXKEYS'; import CONST from '../CONST'; -import {getReportParticipantsTitle, isDefaultRoom, getDefaultRoomSubtitle, isArchivedRoom} from './reportUtils'; +import { + getReportParticipantsTitle, isDefaultRoom, getDefaultRoomSubtitle, isArchivedRoom, +} from './reportUtils'; import {translate} from './translate'; import Permissions from './Permissions'; import md5 from './md5'; diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 9bb5767b4f0a0..00256963b4453 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -19,7 +19,7 @@ import * as API from '../API'; import CONST from '../../CONST'; import Log from '../Log'; import { - isConciergeChatReport, isDefaultRoom, isReportMessageAttachment, sortReportsByLastVisited, + isConciergeChatReport, isDefaultRoom, isReportMessageAttachment, sortReportsByLastVisited, isArchivedRoom, } from '../reportUtils'; import Timers from '../Timers'; import {dangerouslyGetReportActionsMaxSequenceNumber, isReportMissingActions} from './ReportActions'; diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 4564cba699aae..d0bd5fef9e777 100755 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -147,7 +147,7 @@ class ReportActionCompose extends React.Component { this.emojiPopoverAnchor = null; this.emojiSearchInput = null; this.setTextInputRef = this.setTextInputRef.bind(this); - this.getInputPlaceholder = this.getInputPlaceholder.bind(this) + this.getInputPlaceholder = this.getInputPlaceholder.bind(this); this.state = { isFocused: this.shouldFocusInputOnScreenFocus, @@ -234,6 +234,26 @@ class ReportActionCompose extends React.Component { this.textInput = el; } + /** + * Get the placeholder to display in the chat input. + * + * @return {String} + */ + getInputPlaceholder() { + if (isArchivedRoom(this.props.report)) { + return this.props.translate('reportActionCompose.roomIsArchived'); + } + + if (this.props.report.participants + && this.props.report.participants.includes(CONST.EMAIL.CONCIERGE) + && !_.isEmpty(this.props.blockedFromConcierge) + && User.isBlockedFromConcierge(this.props.blockedFromConcierge.expiresAt)) { + return this.props.translate('reportActionCompose.blockedFromConcierge'); + } + + return this.props.translate('reportActionCompose.writeSomething'); + } + /** * Focus the composer text input * @param {Boolean} [shouldelay=false] Impose delay before focusing the composer @@ -378,26 +398,6 @@ class ReportActionCompose extends React.Component { } } - /** - * Get the placeholder to display in the chat input. - * - * @return {String} - */ - getInputPlaceholder() { - if (isArchivedRoom(this.props.report)) { - return this.props.translate('reportActionCompose.roomIsArchived'); - } - - if (this.props.report.participants - && this.props.report.participants.includes(CONST.EMAIL.CONCIERGE) - && !_.isEmpty(this.props.blockedFromConcierge) - && User.isBlockedFromConcierge(this.props.blockedFromConcierge.expiresAt)) { - return this.props.translate('reportActionCompose.blockedFromConcierge'); - } - - return this.props.translate('reportActionCompose.writeSomething'); - } - /** * Add a new comment to this chat * From 49ac1843f44644bb90cb538c5a44c32be260357b Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Thu, 15 Jul 2021 17:21:43 -0700 Subject: [PATCH 5/9] Show old policy name in subheader if we're dealing with an Archived Room --- src/libs/actions/Report.js | 4 ++++ src/libs/reportUtils.js | 33 ++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index f65ff81e9b831..8462a9fba7c36 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -187,6 +187,9 @@ function getSimplifiedReportObject(report) { ? lodashGet(report, ['reportNameValuePairs', 'notificationPreferences', currentUserAccountID], 'daily') : ''; + // Used for archived rooms, will store the policy name that the room used to belong to. + const oldPolicyName = lodashGet(report, ['reportNameValuePairs', 'oldPolicyName'], ''); + return { reportID: report.reportID, reportName, @@ -209,6 +212,7 @@ function getSimplifiedReportObject(report) { notificationPreference, stateNum: report.stateNum, statusNum: report.reportStatus, + oldPolicyName, }; } diff --git a/src/libs/reportUtils.js b/src/libs/reportUtils.js index 0089e997724fc..66f9c4dbae8f6 100644 --- a/src/libs/reportUtils.js +++ b/src/libs/reportUtils.js @@ -102,6 +102,21 @@ function isDefaultRoom(report) { ], lodashGet(report, ['chatType'], '')); } +/** + * Whether the provided report is an archived room + * @param {Object} report + * @param {Number} report.stateNum + * @param {Number} report.statusNum + * @returns {Boolean} + */ +function isArchivedRoom(report) { + if (!isDefaultRoom(report)) { + return false; + } + + return report.statusNum === 2 && report.stateNum === 2; +} + /** * Get either the policyName or domainName the chat is tied to * @param {Object} report @@ -116,6 +131,9 @@ function getDefaultRoomSubtitle(report, policiesMap) { // The domainAll rooms are just #domainName, so we ignore the prefix '#' to get the domainName return report.reportName.substring(1); } + if (isArchivedRoom(report)) { + return report.oldPolicyName; + } return lodashGet( policiesMap, [`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'name'], @@ -123,21 +141,6 @@ function getDefaultRoomSubtitle(report, policiesMap) { ); } -/** - * Whether the provided report is an archived room - * @param {Object} report - * @param {Number} report.stateNum - * @param {Number} report.statusNum - * @returns {Boolean} - */ -function isArchivedRoom(report) { - if (!isDefaultRoom(report)) { - return false; - } - - return report.statusNum === 2 && report.stateNum === 2; -} - /** * Only returns true if this is our main 1:1 DM report with Concierge * From 33e5d99b95e8e7f767c42f5dccbb76879a565387 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Thu, 15 Jul 2021 17:25:15 -0700 Subject: [PATCH 6/9] Stylesheet.flatten --- src/components/Avatar.js | 4 ++-- src/components/RoomAvatar.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/Avatar.js b/src/components/Avatar.js index 08268a36f27ea..c3e64dbac2b2a 100644 --- a/src/components/Avatar.js +++ b/src/components/Avatar.js @@ -1,5 +1,5 @@ import React, {PureComponent} from 'react'; -import {Image, View, StyleSheet} from 'react-native'; +import {Image, View} from 'react-native'; import PropTypes from 'prop-types'; import styles from '../styles/styles'; import RoomAvatar from './RoomAvatar'; @@ -46,7 +46,7 @@ class Avatar extends PureComponent { return ( {this.props.isDefaultChatRoom - ? + ? : } ); diff --git a/src/components/RoomAvatar.js b/src/components/RoomAvatar.js index 47fde87aa71e4..f9675418e542f 100644 --- a/src/components/RoomAvatar.js +++ b/src/components/RoomAvatar.js @@ -1,4 +1,5 @@ import React, {PureComponent} from 'react'; +import {StyleSheet} from 'react-native'; import PropTypes from 'prop-types'; import ActiveRoomAvatar from '../../assets/images/avatars/room.svg'; import DeletedRoomAvatar from '../../assets/images/avatars/deleted-room.svg'; @@ -19,8 +20,8 @@ const defaultProps = { class RoomAvatar extends PureComponent { render() { return (this.props.isArchived - ? - : + ? + : ); } } From 4bb44ed0a2a72f26b505d8c142007d0b458a717c Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Thu, 15 Jul 2021 20:48:15 -0700 Subject: [PATCH 7/9] Use state/status --- src/libs/actions/Report.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 8462a9fba7c36..a5f583edb08a2 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -210,8 +210,8 @@ function getSimplifiedReportObject(report) { lastActorEmail, hasOutstandingIOU: false, notificationPreference, - stateNum: report.stateNum, - statusNum: report.reportStatus, + stateNum: report.state, + statusNum: report.status, oldPolicyName, }; } From 97c649c29cf305899f84534acd32f6c23757e50d Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Fri, 16 Jul 2021 12:46:07 -0700 Subject: [PATCH 8/9] Fix bad merge of master --- src/languages/en.js | 1 - src/languages/es.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index 6d709635ace91..12e18aecbb5c9 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -108,7 +108,6 @@ export default { blockedFromConcierge: 'Communication is barred', youAppearToBeOffline: 'You appear to be offline.', fileUploadFailed: 'Upload Failed. File is not supported.', - localTime: ({user, time}) => `It's ${time} for ${user}`, roomIsArchived: 'This chat room has been deleted', }, contextMenuItem: { diff --git a/src/languages/es.js b/src/languages/es.js index f4fff14ab6e58..6290af5dd0af9 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -103,7 +103,6 @@ export default { writeSomething: 'Escribe algo...', blockedFromConcierge: 'Comunicación no permitida', youAppearToBeOffline: 'Parece que estás desconectado.', - localTime: ({user, time}) => `Son las ${time} para ${user}`, roomIsArchived: 'Esta sala de chat ha sido eliminada', }, reportActionContextMenu: { From 4ee3e732d0c8ac08700f4a33faea5a14ff5ead72 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Mon, 19 Jul 2021 21:51:48 -0700 Subject: [PATCH 9/9] Make deleted icon circular --- assets/images/avatars/deleted-room.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/images/avatars/deleted-room.svg b/assets/images/avatars/deleted-room.svg index a6b59c7b3f533..cfce5daab4404 100644 --- a/assets/images/avatars/deleted-room.svg +++ b/assets/images/avatars/deleted-room.svg @@ -6,7 +6,7 @@ .st0{fill:#C6C9CA;} .st1{fill:#FFFFFF;} - +