Selaa lähdekoodia

feat: Add configuration to disable chat emoticons #9889 (#9899)

master
dimitardelchev93 3 vuotta sitten
vanhempi
commit
db473dfef5
No account linked to committer's email address

+ 3
- 0
config.js Näytä tiedosto

@@ -1017,6 +1017,9 @@ var config = {
1017 1017
     // Prevent the filmstrip from autohiding when screen width is under a certain threshold
1018 1018
     // disableFilmstripAutohiding: false,
1019 1019
 
1020
+    // Specifies whether the chat emoticons are disabled or not
1021
+    // disableChatSmileys: false,
1022
+
1020 1023
     // Allow all above example options to include a trailing comma and
1021 1024
     // prevent fear when commenting out the last value.
1022 1025
     makeJsonParserHappy: 'even if last key had a trailing comma'

+ 1
- 0
react/features/base/config/configWhitelist.js Näytä tiedosto

@@ -83,6 +83,7 @@ export default [
83 83
     'disableAGC',
84 84
     'disableAP',
85 85
     'disableAudioLevels',
86
+    'disableChatSmileys',
86 87
     'disableDeepLinking',
87 88
     'disabledSounds',
88 89
     'disableFilmstripAutohiding',

+ 46
- 21
react/features/chat/components/web/ChatInput.js Näytä tiedosto

@@ -8,6 +8,7 @@ import { isMobileBrowser } from '../../../base/environment/utils';
8 8
 import { translate } from '../../../base/i18n';
9 9
 import { Icon, IconPlane, IconSmile } from '../../../base/icons';
10 10
 import { connect } from '../../../base/redux';
11
+import { areSmileysDisabled } from '../../functions';
11 12
 
12 13
 import SmileysPanel from './SmileysPanel';
13 14
 
@@ -35,7 +36,13 @@ type Props = {
35 36
     /**
36 37
      * Invoked to obtain translated strings.
37 38
      */
38
-    t: Function
39
+    t: Function,
40
+
41
+    /**
42
+     * Whether chat emoticons are disabled.
43
+     */
44
+    _areSmileysDisabled: boolean
45
+
39 46
 };
40 47
 
41 48
 /**
@@ -115,28 +122,31 @@ class ChatInput extends Component<Props, State> {
115 122
         return (
116 123
             <div className = { `chat-input-container${this.state.message.trim().length ? ' populated' : ''}` }>
117 124
                 <div id = 'chat-input' >
118
-                    <div className = 'smiley-input'>
119
-                        <div id = 'smileysarea'>
120
-                            <div id = 'smileys'>
121
-                                <div
122
-                                    aria-expanded = { this.state.showSmileysPanel }
123
-                                    aria-haspopup = 'smileysContainer'
124
-                                    aria-label = { this.props.t('chat.smileysPanel') }
125
-                                    className = 'smiley-button'
126
-                                    onClick = { this._onToggleSmileysPanel }
127
-                                    onKeyDown = { this._onEscHandler }
128
-                                    onKeyPress = { this._onToggleSmileysPanelKeyPress }
129
-                                    role = 'button'
130
-                                    tabIndex = { 0 }>
131
-                                    <Icon src = { IconSmile } />
125
+                    { this.props._areSmileysDisabled ? null : (
126
+                        <div className = 'smiley-input'>
127
+                            <div id = 'smileysarea'>
128
+                                <div id = 'smileys'>
129
+                                    <div
130
+                                        aria-expanded = { this.state.showSmileysPanel }
131
+                                        aria-haspopup = 'smileysContainer'
132
+                                        aria-label = { this.props.t('chat.smileysPanel') }
133
+                                        className = 'smiley-button'
134
+                                        onClick = { this._onToggleSmileysPanel }
135
+                                        onKeyDown = { this._onEscHandler }
136
+                                        onKeyPress = { this._onToggleSmileysPanelKeyPress }
137
+                                        role = 'button'
138
+                                        tabIndex = { 0 }>
139
+                                        <Icon src = { IconSmile } />
140
+                                    </div>
132 141
                                 </div>
133 142
                             </div>
143
+                            <div
144
+                                className = { smileysPanelClassName } >
145
+                                <SmileysPanel
146
+                                    onSmileySelect = { this._onSmileySelect } />
147
+                            </div>
134 148
                         </div>
135
-                        <div className = { smileysPanelClassName }>
136
-                            <SmileysPanel
137
-                                onSmileySelect = { this._onSmileySelect } />
138
-                        </div>
139
-                    </div>
149
+                    ) }
140 150
                     <div className = 'usrmsg-form'>
141 151
                         <TextareaAutosize
142 152
                             autoComplete = 'off'
@@ -336,4 +346,19 @@ class ChatInput extends Component<Props, State> {
336 346
     }
337 347
 }
338 348
 
339
-export default translate(connect()(ChatInput));
349
+/**
350
+ * Function that maps parts of Redux state tree into component props.
351
+ *
352
+ * @param {Object} state - Redux state.
353
+ * @private
354
+ * @returns {{
355
+ *     _areSmileysDisabled: boolean
356
+ * }}
357
+ */
358
+const mapStateToProps = state => {
359
+    return {
360
+        _areSmileysDisabled: areSmileysDisabled(state)
361
+    };
362
+};
363
+
364
+export default translate(connect(mapStateToProps)(ChatInput));

+ 12
- 0
react/features/chat/functions.js Näytä tiedosto

@@ -90,3 +90,15 @@ export function getUnreadMessagesCount(state: Object) {
90 90
 
91 91
     return nbUnreadMessages;
92 92
 }
93
+
94
+/**
95
+ * Get whether the chat smileys are disabled or not.
96
+ *
97
+ * @param {Object} state - The redux state.
98
+ * @returns {boolean} The disabled flag.
99
+ */
100
+export function areSmileysDisabled(state: Object) {
101
+    const disableChatSmileys = state['features/base/config']?.disableChatSmileys === true;
102
+
103
+    return disableChatSmileys;
104
+}

Loading…
Peruuta
Tallenna