From e76361bad0107e0f314dc6f4a27037178e795930 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sat, 30 Dec 2023 12:26:06 +0800 Subject: [PATCH 1/2] show join button --- src/pages/home/HeaderView.js | 223 +++++++++++++++++++---------------- 1 file changed, 120 insertions(+), 103 deletions(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index d3ec573b5886..1e58e3c166b1 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -6,6 +6,7 @@ import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; import GoogleMeetIcon from '@assets/images/google-meet.svg'; import ZoomIcon from '@assets/images/zoom-icon.svg'; +import Button from '@components/Button'; import DisplayNames from '@components/DisplayNames'; import Icon from '@components/Icon'; import * as Expensicons from '@components/Icon/Expensicons'; @@ -141,25 +142,37 @@ function HeaderView(props) { } } - if ((isChatThread && !isEmptyChat) || isUserCreatedPolicyRoom || canLeaveRoom) { - if (!isWhisperAction && props.report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) { - threeDotMenuItems.push({ - icon: Expensicons.ChatBubbles, - text: translate('common.join'), - onSelected: Session.checkIfActionIsAllowed(() => - Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, false), - ), - }); - } else if ((isChatThread && props.report.notificationPreference.length) || isUserCreatedPolicyRoom || canLeaveRoom) { - const isWorkspaceMemberLeavingWorkspaceRoom = lodashGet(props.report, 'visibility', '') === CONST.REPORT.VISIBILITY.RESTRICTED && isPolicyMember; - threeDotMenuItems.push({ - icon: Expensicons.ChatBubbles, - text: translate('common.leave'), - onSelected: Session.checkIfActionIsAllowed(() => Report.leaveRoom(props.report.reportID, isWorkspaceMemberLeavingWorkspaceRoom)), - }); - } + const canJoinOrLeave = (isChatThread && !isEmptyChat) || isUserCreatedPolicyRoom || canLeaveRoom; + const canJoin = canJoinOrLeave && !isWhisperAction && props.report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; + const canLeave = canJoinOrLeave && ((isChatThread && props.report.notificationPreference.length) || isUserCreatedPolicyRoom || canLeaveRoom); + if (canJoin) { + threeDotMenuItems.push({ + icon: Expensicons.ChatBubbles, + text: translate('common.join'), + onSelected: Session.checkIfActionIsAllowed(() => + Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, false), + ), + }); + } else if (canLeave) { + const isWorkspaceMemberLeavingWorkspaceRoom = lodashGet(props.report, 'visibility', '') === CONST.REPORT.VISIBILITY.RESTRICTED && isPolicyMember; + threeDotMenuItems.push({ + icon: Expensicons.ChatBubbles, + text: translate('common.leave'), + onSelected: Session.checkIfActionIsAllowed(() => Report.leaveRoom(props.report.reportID, isWorkspaceMemberLeavingWorkspaceRoom)), + }); } + const joinButton = ( +