Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(groupchat-polls-permissions): Native implementation.

damenchof488ef1e5c36
diff --git a/react/features/chat/components/native/ChatInputBar.tsx b/react/features/chat/components/native/ChatInputBar.tsx
index 8ab498c59e..4f3034b42a 100644
--- a/react/features/chat/components/native/ChatInputBar.tsx
+++ b/react/features/chat/components/native/ChatInputBar.tsx
@@ -12,10 +12,20 @@ import Input from '../../../base/ui/components/native/Input';
import { BUTTON_TYPES } from '../../../base/ui/constants.native';
import styles from './styles';
-
+import { isSendGroupChatDisabled } from '../../functions';
interface IProps extends WithTranslation {
+ /**
+ * Whether sending group chat messages is disabled.
+ */
+ _isSendGroupChatDisabled: boolean;
+
+ /**
+ * The id of the message recipient, if any.
+ */
+ _privateMessageRecipientId?: string;
+
/**
* Application's aspect ratio.
*/
@@ -102,7 +112,8 @@ class ChatInputBar extends Component<IProps, IState> {
returnKeyType = 'send'
value = { this.state.message } />
<IconButton
- disabled = { !this.state.message }
+ disabled = { !this.state.message
+ || (this.props._isSendGroupChatDisabled && !this.props._privateMessageRecipientId) }
id = { this.props.t('chat.sendButton') }
onPress = { this._onSubmit }
src = { IconSend }
@@ -144,9 +155,19 @@ class ChatInputBar extends Component<IProps, IState> {
* @returns {void}
*/
_onSubmit() {
+ const {
+ _isSendGroupChatDisabled,
+ _privateMessageRecipientId,
+ onSend
+ } = this.props;
+
+ if (_isSendGroupChatDisabled && !_privateMessageRecipientId) {
+ return;
+ }
+
const message = this.state.message.trim();
- message && this.props.onSend(message);
+ message && onSend(message);
this.setState({
message: '',
showSend: false
@@ -163,8 +184,12 @@ class ChatInputBar extends Component<IProps, IState> {
*/
function _mapStateToProps(state: IReduxState) {
const { aspectRatio } = state['features/base/responsive-ui'];
+ const { privateMessageRecipient } = state['features/chat'];
+ const isGroupChatDisabled = isSendGroupChatDisabled(state);
return {
+ _isSendGroupChatDisabled: isGroupChatDisabled,
+ _privateMessageRecipientId: privateMessageRecipient?.id,
aspectRatio
};
}
diff --git a/react/features/chat/components/web/ChatInput.tsx b/react/features/chat/components/web/ChatInput.tsx
index c088a9ff86..2e6f06d562 100644
--- a/react/features/chat/components/web/ChatInput.tsx
+++ b/react/features/chat/components/web/ChatInput.tsx
@@ -22,6 +22,9 @@ interface IProps extends WithTranslation {
*/
_areSmileysDisabled: boolean;
+ /**
+ * Whether sending group chat messages is disabled.
+ */
_isSendGroupChatDisabled: boolean;
/**
diff --git a/react/features/polls/components/native/PollsPane.tsx b/react/features/polls/components/native/PollsPane.tsx
index cfa9cb89b0..f4fb15accd 100644
--- a/react/features/polls/components/native/PollsPane.tsx
+++ b/react/features/polls/components/native/PollsPane.tsx
@@ -20,7 +20,7 @@ import PollsList from './PollsList';
import { pollsStyles } from './styles';
const PollsPane = (props: AbstractProps) => {
- const { createMode, onCreate, setCreateMode, t } = props;
+ const { createMode, isCreatePollsDisabled, onCreate, setCreateMode, t } = props;
const navigation = useNavigation();
const { isPollsTabFocused } = useSelector((state: IReduxState) => state['features/chat']);
const { nbUnreadPolls } = useSelector((state: IReduxState) => state['features/polls']);
@@ -57,6 +57,7 @@ const PollsPane = (props: AbstractProps) => {
<PollsList setCreateMode = { setCreateMode } />
<Button
accessibilityLabel = 'polls.create.create'
+ disabled = { isCreatePollsDisabled }
id = { t('polls.create.create') }
labelKey = 'polls.create.create'
onClick = { onCreate }