From 9cab0d412a22e6caae3e03287d557c0a8763153e Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 23 Jun 2023 14:07:15 +0700 Subject: [PATCH 1/8] hide emojiPicker when composer is hide --- src/libs/ReportUtils.js | 11 +++++++++++ src/pages/home/ReportScreen.js | 3 +++ src/pages/home/report/ReportFooter.js | 4 +--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 64a07113cb51..4c94a1891769 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2258,6 +2258,16 @@ function getParentReport(report) { return lodashGet(allReports, `${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`, {}); } +/** + * Whether the composer should be hide + * @param {Object} report + * @param {Object} errors + * @returns {Boolean} + */ +function shouldHideComposer(report, errors) { + return isArchivedRoom(report) || !_.isEmpty(errors) || isAllowedToComment(report); +} + export { getReportParticipantsTitle, isReportMessageAttachment, @@ -2350,4 +2360,5 @@ export { getMoneyRequestAction, getBankAccountRoute, getParentReport, + shouldHideComposer, }; diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index d3fb665ecb48..db991994e5bd 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -152,6 +152,9 @@ class ReportScreen extends React.Component { } componentDidUpdate(prevProps) { + if (ReportUtils.shouldHideComposer(this.props.report, this.props.errors)) { + EmojiPickerAction.hideEmojiPicker(); + } // If you already have a report open and are deeplinking to a new report on native, // the ReportScreen never actually unmounts and the reportID in the route also doesn't change. // Therefore, we need to compare if the existing reportID is the same as the one in the route diff --git a/src/pages/home/report/ReportFooter.js b/src/pages/home/report/ReportFooter.js index 92838ecf9451..50a84c2f2fea 100644 --- a/src/pages/home/report/ReportFooter.js +++ b/src/pages/home/report/ReportFooter.js @@ -1,5 +1,4 @@ import React from 'react'; -import _ from 'underscore'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import {View, Keyboard} from 'react-native'; @@ -60,8 +59,7 @@ const defaultProps = { function ReportFooter(props) { const chatFooterStyles = {...styles.chatFooter, minHeight: !props.isOffline ? CONST.CHAT_FOOTER_MIN_HEIGHT : 0}; const isArchivedRoom = ReportUtils.isArchivedRoom(props.report); - const isAllowedToComment = ReportUtils.isAllowedToComment(props.report); - const hideComposer = isArchivedRoom || !_.isEmpty(props.errors) || !isAllowedToComment; + const hideComposer = ReportUtils.shouldHideComposer(props.report, props.errors); return ( <> From 8fc0bc9503e83d6a7ad330b6e9af06a0b26db700 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 23 Jun 2023 15:39:55 +0700 Subject: [PATCH 2/8] remove utils function --- src/pages/home/ReportScreen.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index db991994e5bd..9306895eacb5 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -152,8 +152,11 @@ class ReportScreen extends React.Component { } componentDidUpdate(prevProps) { - if (ReportUtils.shouldHideComposer(this.props.report, this.props.errors)) { - EmojiPickerAction.hideEmojiPicker(); + const isArchivedRoom = ReportUtils.isArchivedRoom(this.props.report); + const isAllowedToComment = ReportUtils.isAllowedToComment(this.props.report); + const hideEmojiPicker = isArchivedRoom || !_.isEmpty(this.props.errors) || !isAllowedToComment; + if(hideEmojiPicker) { + EmojiPickerAction.hideEmojiPicker() } // If you already have a report open and are deeplinking to a new report on native, // the ReportScreen never actually unmounts and the reportID in the route also doesn't change. From 2e7501a422b740bcd1c3c2e9c38585f8901ce552 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 23 Jun 2023 16:28:14 +0700 Subject: [PATCH 3/8] use utils function --- src/libs/ReportUtils.js | 2 +- src/pages/home/ReportScreen.js | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 4c94a1891769..c59c45e01e67 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2265,7 +2265,7 @@ function getParentReport(report) { * @returns {Boolean} */ function shouldHideComposer(report, errors) { - return isArchivedRoom(report) || !_.isEmpty(errors) || isAllowedToComment(report); + return isArchivedRoom(report) || !_.isEmpty(errors) || !isAllowedToComment(report); } export { diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 9306895eacb5..db991994e5bd 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -152,11 +152,8 @@ class ReportScreen extends React.Component { } componentDidUpdate(prevProps) { - const isArchivedRoom = ReportUtils.isArchivedRoom(this.props.report); - const isAllowedToComment = ReportUtils.isAllowedToComment(this.props.report); - const hideEmojiPicker = isArchivedRoom || !_.isEmpty(this.props.errors) || !isAllowedToComment; - if(hideEmojiPicker) { - EmojiPickerAction.hideEmojiPicker() + if (ReportUtils.shouldHideComposer(this.props.report, this.props.errors)) { + EmojiPickerAction.hideEmojiPicker(); } // If you already have a report open and are deeplinking to a new report on native, // the ReportScreen never actually unmounts and the reportID in the route also doesn't change. From 0e0b0d5413f871b81597dfafe43daa5b04300250 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 23 Jun 2023 16:30:33 +0700 Subject: [PATCH 4/8] update comment --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index c59c45e01e67..6565a7f5fd86 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2259,7 +2259,7 @@ function getParentReport(report) { } /** - * Whether the composer should be hide + * Return true if the composer should be hide * @param {Object} report * @param {Object} errors * @returns {Boolean} From 89be97c7d92344f438cc61a5cc75db9c59baaa7b Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 23 Jun 2023 16:58:11 +0700 Subject: [PATCH 5/8] add param to hide function --- src/pages/home/ReportScreen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index db991994e5bd..f5bf30767057 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -153,7 +153,7 @@ class ReportScreen extends React.Component { componentDidUpdate(prevProps) { if (ReportUtils.shouldHideComposer(this.props.report, this.props.errors)) { - EmojiPickerAction.hideEmojiPicker(); + EmojiPickerAction.hideEmojiPicker(true); } // If you already have a report open and are deeplinking to a new report on native, // the ReportScreen never actually unmounts and the reportID in the route also doesn't change. From 753e6cc8e2aa3636b371ed1260a7cd8f1c8197b8 Mon Sep 17 00:00:00 2001 From: dukenv0307 <129500732+dukenv0307@users.noreply.github.com> Date: Tue, 27 Jun 2023 18:39:19 +0700 Subject: [PATCH 6/8] Update src/libs/ReportUtils.js Co-authored-by: Sahil --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index fce1e62defbf..dfa0d336a654 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2259,7 +2259,7 @@ function getParentReport(report) { } /** - * Return true if the composer should be hide + * Return true if the composer should be hidden * @param {Object} report * @param {Object} errors * @returns {Boolean} From fa48c39fd4d018f76aff55b04cbd61ef6dcb1513 Mon Sep 17 00:00:00 2001 From: dukenv0307 <129500732+dukenv0307@users.noreply.github.com> Date: Tue, 27 Jun 2023 18:39:25 +0700 Subject: [PATCH 7/8] Update src/pages/home/ReportScreen.js Co-authored-by: Sahil --- src/pages/home/ReportScreen.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 5f52931a8e50..758cb28a7279 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -155,6 +155,7 @@ class ReportScreen extends React.Component { } componentDidUpdate(prevProps) { + // If composer should be hidden, hide emoji picker as well if (ReportUtils.shouldHideComposer(this.props.report, this.props.errors)) { EmojiPickerAction.hideEmojiPicker(true); } From 05ea1718c56523030331f9920230fa3b0160852a Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 28 Jun 2023 16:54:45 +0700 Subject: [PATCH 8/8] update the name of params --- src/libs/ReportUtils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index dfa0d336a654..3a03903b0cf8 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2261,11 +2261,11 @@ function getParentReport(report) { /** * Return true if the composer should be hidden * @param {Object} report - * @param {Object} errors + * @param {Object} reportErrors * @returns {Boolean} */ -function shouldHideComposer(report, errors) { - return isArchivedRoom(report) || !_.isEmpty(errors) || !isAllowedToComment(report); +function shouldHideComposer(report, reportErrors) { + return isArchivedRoom(report) || !_.isEmpty(reportErrors) || !isAllowedToComment(report); } /**