-
Notifications
You must be signed in to change notification settings - Fork 298
Expand file tree
/
Copy pathSendToChannelCheckbox.tsx
More file actions
35 lines (31 loc) · 1.24 KB
/
SendToChannelCheckbox.tsx
File metadata and controls
35 lines (31 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { useMessageComposer } from './hooks';
import React from 'react';
import type { MessageComposerState } from 'stream-chat';
import { useStateStore } from '../../store';
import { useTranslationContext } from '../../context';
const stateSelector = (state: MessageComposerState) => ({
showReplyInChannel: state.showReplyInChannel,
});
export const SendToChannelCheckbox = () => {
const { t } = useTranslationContext();
const messageComposer = useMessageComposer();
const { showReplyInChannel } = useStateStore(messageComposer.state, stateSelector);
if (messageComposer.editedMessage || !messageComposer.threadId) return null;
return (
<div className='str-chat__send-to-channel-checkbox__container'>
<div className='str-chat__send-to-channel-checkbox__field'>
<input
id='send-to-channel-checkbox'
onClick={messageComposer.toggleShowReplyInChannel}
type='checkbox'
value={showReplyInChannel.toString()}
/>
<label htmlFor='send-to-channel-checkbox'>
{Object.keys(messageComposer.channel.state.members).length === 2
? t<string>('Also send as a direct message')
: t<string>('Also send in channel')}
</label>
</div>
</div>
);
};