Переглянути джерело

feat(external_api) set and cancel private chat through external API

- allow managing chat through API when chat button is not present on UI
master
hmuresan 4 роки тому
джерело
коміт
0a5910f0b3

+ 20
- 1
modules/API/API.js Переглянути файл

@@ -14,7 +14,8 @@ import {
14 14
 } from '../../react/features/base/conference';
15 15
 import { parseJWTFromURLParams } from '../../react/features/base/jwt';
16 16
 import JitsiMeetJS, { JitsiRecordingConstants } from '../../react/features/base/lib-jitsi-meet';
17
-import { pinParticipant } from '../../react/features/base/participants';
17
+import { pinParticipant, getParticipantById } from '../../react/features/base/participants';
18
+import { setPrivateMessageRecipient } from '../../react/features/chat/actions';
18 19
 import {
19 20
     processExternalDeviceRequest
20 21
 } from '../../react/features/device-selection/functions';
@@ -330,6 +331,24 @@ function initCommands() {
330 331
             } else {
331 332
                 logger.error('No recording or streaming session found');
332 333
             }
334
+        },
335
+        'initiate-private-chat': participantId => {
336
+            const state = APP.store.getState();
337
+            const participant = getParticipantById(state, participantId);
338
+
339
+            if (participant) {
340
+                const { isOpen: isChatOpen } = state['features/chat'];
341
+
342
+                if (!isChatOpen) {
343
+                    APP.UI.toggleChat();
344
+                }
345
+                APP.store.dispatch(setPrivateMessageRecipient(participant));
346
+            } else {
347
+                logger.error('No participant found for the given participantId');
348
+            }
349
+        },
350
+        'cancel-private-chat': () => {
351
+            APP.store.dispatch(setPrivateMessageRecipient());
333 352
         }
334 353
     };
335 354
     transport.on('event', ({ data, name }) => {

+ 2
- 0
modules/API/external/external_api.js Переглянути файл

@@ -28,11 +28,13 @@ const ALWAYS_ON_TOP_FILENAMES = [
28 28
  */
29 29
 const commands = {
30 30
     avatarUrl: 'avatar-url',
31
+    cancelPrivateChat: 'cancel-private-chat',
31 32
     displayName: 'display-name',
32 33
     e2eeKey: 'e2ee-key',
33 34
     email: 'email',
34 35
     toggleLobby: 'toggle-lobby',
35 36
     hangup: 'video-hangup',
37
+    intiatePrivateChat: 'initiate-private-chat',
36 38
     muteEveryone: 'mute-everyone',
37 39
     password: 'password',
38 40
     pinParticipant: 'pin-participant',

+ 3
- 5
react/features/chat/middleware.js Переглянути файл

@@ -19,7 +19,6 @@ import {
19 19
 import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
20 20
 import { playSound, registerSound, unregisterSound } from '../base/sounds';
21 21
 import { showToolbox } from '../toolbox/actions';
22
-import { isButtonEnabled } from '../toolbox/functions';
23 22
 
24 23
 import { SEND_MESSAGE, SET_PRIVATE_MESSAGE_RECIPIENT } from './actionTypes';
25 24
 import { addMessage, clearMessages, toggleChat } from './actions';
@@ -152,10 +151,9 @@ StateListenerRegistry.register(
152 151
  * @returns {void}
153 152
  */
154 153
 function _addChatMsgListener(conference, store) {
155
-    if ((typeof APP !== 'undefined' && !isButtonEnabled('chat'))
156
-        || store.getState()['features/base/config'].iAmRecorder) {
157
-        // We don't register anything on web if the chat button is not enabled in interfaceConfig
158
-        // or we are in iAmRecorder mode
154
+
155
+    if (store.getState()['features/base/config'].iAmRecorder) {
156
+        // We don't register anything on web if we are in iAmRecorder mode
159 157
         return;
160 158
     }
161 159
 

Завантаження…
Відмінити
Зберегти