Skip to content

Commit

Permalink
Merge pull request #38571 from nkdengineer/fix/37688
Browse files Browse the repository at this point in the history
fix create block send message view
  • Loading branch information
luacmartins authored May 28, 2024
2 parents 1669f82 + 88bc2c6 commit f6de985
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ const ONYXKEYS = {
/** Contains the users's block expiration (if they have one) */
NVP_BLOCKED_FROM_CONCIERGE: 'nvp_private_blockedFromConcierge',

/** Whether the user is blocked from chat */
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',

Expand Down Expand Up @@ -618,6 +621,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.BETAS]: OnyxTypes.Beta[];
[ONYXKEYS.NVP_PRIORITY_MODE]: ValueOf<typeof CONST.PRIORITY_MODE>;
[ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE]: OnyxTypes.BlockedFromConcierge;
[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;
Expand Down
24 changes: 24 additions & 0 deletions src/components/BlockedReportFooter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Banner from './Banner';

function BlockedReportFooter() {
const styles = useThemeStyles();
const {translate} = useLocalize();

const text = translate('youHaveBeenBanned');

return (
<Banner
containerStyles={[styles.archivedReportFooter]}
text={text}
shouldShowIcon
shouldRenderHTML
/>
);
}

BlockedReportFooter.displayName = 'ArchivedReportFooter';

export default BlockedReportFooter;
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ export default {
hereAlternateText: 'Notify everyone in this conversation',
},
newMessages: 'New messages',
youHaveBeenBanned: 'Note: You have been banned from communicating in this channel',
reportTypingIndicator: {
isTyping: 'is typing...',
areTyping: 'are typing...',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ export default {
hereAlternateText: 'Notificar a todos en esta conversación',
},
newMessages: 'Mensajes nuevos',
youHaveBeenBanned: 'Nota: Se te ha prohibido comunicarte en este canal',
reportTypingIndicator: {
isTyping: 'está escribiendo...',
areTyping: 'están escribiendo...',
Expand Down
11 changes: 10 additions & 1 deletion src/pages/home/report/ReportFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -30,6 +31,9 @@ type ReportFooterOnyxProps = {

/** Session info for the currently logged in user. */
session: OnyxEntry<OnyxTypes.Session>;

/** Whether user is blocked from chat. */
blockedFromChat: OnyxEntry<string>;
};

type ReportFooterProps = ReportFooterOnyxProps & {
Expand Down Expand Up @@ -74,6 +78,7 @@ function ReportFooter({
isReportReadyForDisplay = true,
listHeight = 0,
isComposerFullSize = false,
blockedFromChat,
onComposerBlur,
onComposerFocus,
}: ReportFooterProps) {
Expand All @@ -85,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);

Expand Down Expand Up @@ -153,6 +158,7 @@ function ReportFooter({
/>
)}
{isArchivedRoom && <ArchivedReportFooter report={report} />}
{!isArchivedRoom && blockedFromChat && <BlockedReportFooter />}
{!isAnonymousUser && !canWriteInReport && isSystemChat && <SystemChatReportFooterMessage />}
{!isSmallScreenWidth && <View style={styles.offlineIndicatorRow}>{hideComposer && <OfflineIndicator containerStyles={[styles.chatItemComposeSecondaryRow]} />}</View>}
</View>
Expand Down Expand Up @@ -190,6 +196,9 @@ export default withOnyx<ReportFooterProps, ReportFooterOnyxProps>({
session: {
key: ONYXKEYS.SESSION,
},
blockedFromChat: {
key: ONYXKEYS.NVP_BLOCKED_FROM_CHAT,
},
})(
memo(
ReportFooter,
Expand Down

0 comments on commit f6de985

Please sign in to comment.