Skip to content
Merged
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
25 changes: 16 additions & 9 deletions src/modules/OpenChannel/components/OpenChannelInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,33 @@ export type MessageInputWrapperProps = {
value?: string;
};

const MessageInputWrapper = (props: MessageInputWrapperProps, ref: React.RefObject<HTMLInputElement>): JSX.Element => {
const MessageInputWrapper = (props: MessageInputWrapperProps, ref: React.RefObject<HTMLInputElement>): React.ReactNode => {
const {
currentOpenChannel,
disabled,
handleSendMessage,
handleFileUpload,
amIMuted,
} = useOpenChannelContext();

const channel = currentOpenChannel;
if (!channel) {
return;
}

const { stringSet } = useContext(LocalizationContext);
const { value } = props;

function getPlaceHolderString() {
if (amIMuted) {
return stringSet.MESSAGE_INPUT__PLACE_HOLDER__MUTED;
}
if (disabled) {
return stringSet.MESSAGE_INPUT__PLACE_HOLDER__DISABLED;
}
return '';
}

if (!channel) {
return null;
}
return (
<div className="sendbird-openchannel-footer">
<MessageInput
Expand All @@ -32,11 +43,7 @@ const MessageInputWrapper = (props: MessageInputWrapperProps, ref: React.RefObje
isVoiceMessageEnabled={false}
onSendMessage={handleSendMessage}
onFileUpload={handleFileUpload}
placeholder={(
disabled
&& stringSet.MESSAGE_INPUT__PLACE_HOLDER__DISABLED
// add disabled because of muted state
)}
placeholder={getPlaceHolderString()}
/>
</div>
);
Expand Down