Skip to content

Commit

Permalink
fix: show unblock to send placeholder
Browse files Browse the repository at this point in the history
because **consistency**
  • Loading branch information
Bilb committed Nov 26, 2024
1 parent 7d81fd1 commit bfafcaf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions ts/components/conversation/composition/CompositionBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
getSelectedConversation,
} from '../../../state/selectors/conversations';
import {
getIsSelectedBlocked,
getSelectedCanWrite,
getSelectedConversationKey,
} from '../../../state/selectors/selectedConversation';
Expand Down Expand Up @@ -102,6 +103,7 @@ interface Props {
selectedConversationKey?: string;
selectedConversation: ReduxConversationType | undefined;
typingEnabled: boolean;
isBlocked: boolean;
quotedMessageProps?: ReplyingToMessageProps;
stagedAttachments: Array<StagedAttachmentType>;
onChoseAttachments: (newAttachments: Array<File>) => void;
Expand Down Expand Up @@ -389,7 +391,7 @@ class CompositionBoxInner extends Component<Props, State> {

private renderCompositionView() {
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've got a message body OR
Expand All @@ -400,7 +402,9 @@ class CompositionBoxInner extends Component<Props, State> {
/* eslint-disable @typescript-eslint/no-misused-promises */

// 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;
}

Expand All @@ -412,7 +416,7 @@ class CompositionBoxInner extends Component<Props, State> {
alignItems={'center'}
width={'100%'}
>
<AddStagedAttachmentButton onClick={this.onChooseAttachment} />
{typingEnabled && <AddStagedAttachmentButton onClick={this.onChooseAttachment} />}
<input
className="hidden"
placeholder="Attachment"
Expand All @@ -421,7 +425,7 @@ class CompositionBoxInner extends Component<Props, State> {
type="file"
onChange={this.onChoseAttachment}
/>
<StartRecordingButton onClick={this.onLoadVoiceNoteView} />
{typingEnabled && <StartRecordingButton onClick={this.onLoadVoiceNoteView} />}
<StyledSendMessageInput
role="main"
dir={this.props.htmlDirection}
Expand Down Expand Up @@ -1027,6 +1031,7 @@ const mapStateToProps = (state: StateType) => {
selectedConversation: getSelectedConversation(state),
selectedConversationKey: getSelectedConversationKey(state),
typingEnabled: getSelectedCanWrite(state),
isBlocked: getIsSelectedBlocked(state),
};
};

Expand Down
2 changes: 1 addition & 1 deletion ts/state/selectors/selectedConversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const getIsSelectedPrivate = (state: StateType): boolean => {
return Boolean(getSelectedConversation(state)?.isPrivate) || false;
};

const getIsSelectedBlocked = (state: StateType): boolean => {
export const getIsSelectedBlocked = (state: StateType): boolean => {
return Boolean(getSelectedConversation(state)?.isBlocked) || false;
};

Expand Down

0 comments on commit bfafcaf

Please sign in to comment.