Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix create block send message view #38571

Merged
merged 8 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -614,6 +617,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 />}
Copy link
Contributor

@roryabraham roryabraham Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is causing a console error on main (may crash on iOS/Android):

Unexpected text node: . A text node cannot be a child of a <View>.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roryabraham Can you tell me how to reproduce the bug, pls?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created #43083 to fix it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just open any report

{!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
Loading