fix: show unblock to send placeholder

because **consistency**
pull/3281/head
Audric Ackermann 1 year ago
parent 7d81fd169e
commit bfafcaf446
No known key found for this signature in database

@ -26,6 +26,7 @@ import {
getSelectedConversation, getSelectedConversation,
} from '../../../state/selectors/conversations'; } from '../../../state/selectors/conversations';
import { import {
getIsSelectedBlocked,
getSelectedCanWrite, getSelectedCanWrite,
getSelectedConversationKey, getSelectedConversationKey,
} from '../../../state/selectors/selectedConversation'; } from '../../../state/selectors/selectedConversation';
@ -102,6 +103,7 @@ interface Props {
selectedConversationKey?: string; selectedConversationKey?: string;
selectedConversation: ReduxConversationType | undefined; selectedConversation: ReduxConversationType | undefined;
typingEnabled: boolean; typingEnabled: boolean;
isBlocked: boolean;
quotedMessageProps?: ReplyingToMessageProps; quotedMessageProps?: ReplyingToMessageProps;
stagedAttachments: Array<StagedAttachmentType>; stagedAttachments: Array<StagedAttachmentType>;
onChoseAttachments: (newAttachments: Array<File>) => void; onChoseAttachments: (newAttachments: Array<File>) => void;
@ -389,7 +391,7 @@ class CompositionBoxInner extends Component<Props, State> {
private renderCompositionView() { private renderCompositionView() {
const { showEmojiPanel } = this.state; const { showEmojiPanel } = this.state;
const { typingEnabled } = this.props; const { typingEnabled, isBlocked } = this.props;
// we can only send a message if the conversation allows writing in it AND // we can only send a message if the conversation allows writing in it AND
// - we've got a message body OR // - we've got a message body OR
@ -400,7 +402,9 @@ class CompositionBoxInner extends Component<Props, State> {
/* eslint-disable @typescript-eslint/no-misused-promises */ /* eslint-disable @typescript-eslint/no-misused-promises */
// we completely hide the composition box when typing is not enabled now. // we completely hide the composition box when typing is not enabled now.
if (!typingEnabled) { // Actually not anymore. We want the above, except when we can't write because that user is blocked.
// When that user is blocked, **and only then**, we want to show the composition box, disabled with the placeholder "unblock to send".
if (!typingEnabled && !isBlocked) {
return null; return null;
} }
@ -412,7 +416,7 @@ class CompositionBoxInner extends Component<Props, State> {
alignItems={'center'} alignItems={'center'}
width={'100%'} width={'100%'}
> >
<AddStagedAttachmentButton onClick={this.onChooseAttachment} /> {typingEnabled && <AddStagedAttachmentButton onClick={this.onChooseAttachment} />}
<input <input
className="hidden" className="hidden"
placeholder="Attachment" placeholder="Attachment"
@ -421,7 +425,7 @@ class CompositionBoxInner extends Component<Props, State> {
type="file" type="file"
onChange={this.onChoseAttachment} onChange={this.onChoseAttachment}
/> />
<StartRecordingButton onClick={this.onLoadVoiceNoteView} /> {typingEnabled && <StartRecordingButton onClick={this.onLoadVoiceNoteView} />}
<StyledSendMessageInput <StyledSendMessageInput
role="main" role="main"
dir={this.props.htmlDirection} dir={this.props.htmlDirection}
@ -1027,6 +1031,7 @@ const mapStateToProps = (state: StateType) => {
selectedConversation: getSelectedConversation(state), selectedConversation: getSelectedConversation(state),
selectedConversationKey: getSelectedConversationKey(state), selectedConversationKey: getSelectedConversationKey(state),
typingEnabled: getSelectedCanWrite(state), typingEnabled: getSelectedCanWrite(state),
isBlocked: getIsSelectedBlocked(state),
}; };
}; };

@ -23,7 +23,7 @@ const getIsSelectedPrivate = (state: StateType): boolean => {
return Boolean(getSelectedConversation(state)?.isPrivate) || false; return Boolean(getSelectedConversation(state)?.isPrivate) || false;
}; };
const getIsSelectedBlocked = (state: StateType): boolean => { export const getIsSelectedBlocked = (state: StateType): boolean => {
return Boolean(getSelectedConversation(state)?.isBlocked) || false; return Boolean(getSelectedConversation(state)?.isBlocked) || false;
}; };

Loading…
Cancel
Save