From 6590db4e213d998e3de3b71fc746a64a61422498 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 19 Mar 2024 18:32:39 +0700 Subject: [PATCH 1/6] fix create block send message view --- src/ONYXKEYS.ts | 4 ++++ src/components/BlockedReportFooter.tsx | 23 +++++++++++++++++++++++ src/pages/home/report/ReportFooter.tsx | 12 +++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/components/BlockedReportFooter.tsx diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index d7f3104cd8b4..a335cb6f6c7c 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -113,6 +113,9 @@ const ONYXKEYS = { /** Contains the users's block expiration (if they have one) */ NVP_BLOCKED_FROM_CONCIERGE: 'private_blockedFromConcierge', + /** Whether the user is blocked from chat */ + NVP_BLOCKED_FROM_CHAT: 'nvp_privateBlockedFromChat', + /** A unique identifier that each user has that's used to send notifications */ NVP_PRIVATE_PUSH_NOTIFICATION_ID: 'private_pushNotificationID', @@ -533,6 +536,7 @@ type OnyxValuesMapping = { [ONYXKEYS.BETAS]: OnyxTypes.Beta[]; [ONYXKEYS.NVP_PRIORITY_MODE]: ValueOf; [ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE]: OnyxTypes.BlockedFromConcierge; + [ONYXKEYS.NVP_BLOCKED_FROM_CHAT]: boolean; [ONYXKEYS.NVP_PRIVATE_PUSH_NOTIFICATION_ID]: string; [ONYXKEYS.NVP_TRY_FOCUS_MODE]: boolean; [ONYXKEYS.NVP_HOLD_USE_EXPLAINED]: boolean; diff --git a/src/components/BlockedReportFooter.tsx b/src/components/BlockedReportFooter.tsx new file mode 100644 index 000000000000..b945bfd6f927 --- /dev/null +++ b/src/components/BlockedReportFooter.tsx @@ -0,0 +1,23 @@ +import React from 'react'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Banner from './Banner'; + +function ArchivedReportFooter() { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + + const text = 'Note: You have been banned from communicating in this channel'; + + return ( + + ); +} + +ArchivedReportFooter.displayName = 'ArchivedReportFooter'; + +export default ArchivedReportFooter; diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index 3a787e1dbd0f..d1d35195fc09 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -5,6 +5,7 @@ import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import AnonymousReportFooter from '@components/AnonymousReportFooter'; import ArchivedReportFooter from '@components/ArchivedReportFooter'; +import BlockedReportFooter from '@components/BlockedReportFooter'; import OfflineIndicator from '@components/OfflineIndicator'; import {usePersonalDetails} from '@components/OnyxProvider'; import SwipeableView from '@components/SwipeableView'; @@ -28,6 +29,9 @@ type ReportFooterOnyxProps = { /** Session info for the currently logged in user. */ session: OnyxEntry; + + /** Whether user is blocked from chat. */ + blockedFromChat: OnyxEntry; }; type ReportFooterProps = ReportFooterOnyxProps & { @@ -63,6 +67,7 @@ function ReportFooter({ isReportReadyForDisplay = true, listHeight = 0, isComposerFullSize = false, + blockedFromChat, }: ReportFooterProps) { const styles = useThemeStyles(); const {isOffline} = useNetwork(); @@ -72,7 +77,7 @@ function ReportFooter({ const isAnonymousUser = session?.authTokenType === CONST.AUTH_TOKEN_TYPES.ANONYMOUS; const isSmallSizeLayout = windowWidth - (isSmallScreenWidth ? 0 : variables.sideBarWidth) < variables.anonymousReportFooterBreakpoint; - const hideComposer = !ReportUtils.canUserPerformWriteAction(report); + const hideComposer = !ReportUtils.canUserPerformWriteAction(report) || blockedFromChat; const allPersonalDetails = usePersonalDetails(); @@ -128,6 +133,7 @@ function ReportFooter({ /> )} {isArchivedRoom && } + {!isArchivedRoom && blockedFromChat && } {!isSmallScreenWidth && {hideComposer && }} )} @@ -163,6 +169,10 @@ export default withOnyx({ session: { key: ONYXKEYS.SESSION, }, + blockedFromChat: { + key: ONYXKEYS.NVP_BLOCKED_FROM_CHAT, + + }, })( memo( ReportFooter, From fa5e9e83f2a45498d8294683e206d618199aa135 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 22 Mar 2024 02:12:29 +0700 Subject: [PATCH 2/6] fix add translations --- src/components/BlockedReportFooter.tsx | 8 ++++---- src/languages/en.ts | 1 + src/languages/es.ts | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/BlockedReportFooter.tsx b/src/components/BlockedReportFooter.tsx index b945bfd6f927..b97c7dbc4f5e 100644 --- a/src/components/BlockedReportFooter.tsx +++ b/src/components/BlockedReportFooter.tsx @@ -3,11 +3,11 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Banner from './Banner'; -function ArchivedReportFooter() { +function BlockedReportFooter() { const styles = useThemeStyles(); const {translate} = useLocalize(); - const text = 'Note: You have been banned from communicating in this channel'; + const text = translate('youHaveBeenBanned'); return ( Date: Fri, 22 Mar 2024 02:24:40 +0700 Subject: [PATCH 3/6] fix lint --- src/pages/home/report/ReportFooter.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index d1d35195fc09..e5a3345c1a63 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -171,7 +171,6 @@ export default withOnyx({ }, blockedFromChat: { key: ONYXKEYS.NVP_BLOCKED_FROM_CHAT, - }, })( memo( From ca31854162da168f17f2092295ea142ddde8115a Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 27 May 2024 14:35:00 +0700 Subject: [PATCH 4/6] fix conflict --- src/ONYXKEYS.ts | 2 +- src/pages/home/report/ReportFooter.tsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 76f2efe34bc1..54cfca3115e1 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -122,7 +122,7 @@ const ONYXKEYS = { NVP_BLOCKED_FROM_CONCIERGE: 'nvp_private_blockedFromConcierge', /** Whether the user is blocked from chat */ - NVP_BLOCKED_FROM_CHAT: 'nvp_privateBlockedFromChat', + NVP_BLOCKED_FROM_CHAT: 'nvp_private_blockedFromChat', /** A unique identifier that each user has that's used to send notifications */ NVP_PRIVATE_PUSH_NOTIFICATION_ID: 'nvp_private_pushNotificationID', diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index 8fa2caa94072..a44517e79656 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -90,7 +90,7 @@ function ReportFooter({ const isAnonymousUser = session?.authTokenType === CONST.AUTH_TOKEN_TYPES.ANONYMOUS; const isSmallSizeLayout = windowWidth - (isSmallScreenWidth ? 0 : variables.sideBarWidth) < variables.anonymousReportFooterBreakpoint; - const hideComposer = !ReportUtils.canUserPerformWriteAction(report, reportNameValuePairs); + const hideComposer = !ReportUtils.canUserPerformWriteAction(report, reportNameValuePairs) || blockedFromChat; const canWriteInReport = ReportUtils.canWriteInReport(report); const isSystemChat = ReportUtils.isSystemChat(report); @@ -158,6 +158,7 @@ function ReportFooter({ /> )} {isArchivedRoom && } + {!isArchivedRoom && blockedFromChat && } {!isAnonymousUser && !canWriteInReport && isSystemChat && } {!isSmallScreenWidth && {hideComposer && }} From e718d2db8e0a4ffdec32bce795421ca347fdb994 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 27 May 2024 14:59:29 +0700 Subject: [PATCH 5/6] fix type --- src/ONYXKEYS.ts | 2 +- src/pages/home/report/ReportFooter.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 54cfca3115e1..9b5bd82d0b69 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -617,7 +617,7 @@ type OnyxValuesMapping = { [ONYXKEYS.BETAS]: OnyxTypes.Beta[]; [ONYXKEYS.NVP_PRIORITY_MODE]: ValueOf; [ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE]: OnyxTypes.BlockedFromConcierge; - [ONYXKEYS.NVP_BLOCKED_FROM_CHAT]: boolean; + [ONYXKEYS.NVP_BLOCKED_FROM_CHAT]: string; [ONYXKEYS.NVP_PRIVATE_PUSH_NOTIFICATION_ID]: string; [ONYXKEYS.NVP_TRY_FOCUS_MODE]: boolean; [ONYXKEYS.NVP_HOLD_USE_EXPLAINED]: boolean; diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index a44517e79656..ac56fe916bc9 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -33,7 +33,7 @@ type ReportFooterOnyxProps = { session: OnyxEntry; /** Whether user is blocked from chat. */ - blockedFromChat: OnyxEntry; + blockedFromChat: OnyxEntry; }; type ReportFooterProps = ReportFooterOnyxProps & { From 88bc2c658d019d8d6e44b257315ea002b245493e Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 27 May 2024 15:12:50 +0700 Subject: [PATCH 6/6] fix banner issue --- src/components/BlockedReportFooter.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/BlockedReportFooter.tsx b/src/components/BlockedReportFooter.tsx index b97c7dbc4f5e..89290545166c 100644 --- a/src/components/BlockedReportFooter.tsx +++ b/src/components/BlockedReportFooter.tsx @@ -14,6 +14,7 @@ function BlockedReportFooter() { containerStyles={[styles.archivedReportFooter]} text={text} shouldShowIcon + shouldRenderHTML /> ); }