Procházet zdrojové kódy

ref(modules/UI): remove events system.

Many of the events are not used at all or used only on one place. For the rest of them the listeners were added 2 times on promoted visitors and not cleaned at all.
factor2
Hristo Terezov před 1 rokem
rodič
revize
9bb27b83d9

+ 98
- 143
conference.js Zobrazit soubor

@@ -2,7 +2,6 @@
2 2
 
3 3
 import { jitsiLocalStorage } from '@jitsi/js-utils';
4 4
 import Logger from '@jitsi/logger';
5
-import EventEmitter from 'events';
6 5
 
7 6
 import { ENDPOINT_TEXT_MESSAGE_NAME } from './modules/API/constants';
8 7
 import { AUDIO_ONLY_SCREEN_SHARE_NO_TRACK } from './modules/UI/UIErrors';
@@ -165,12 +164,9 @@ import { AudioMixerEffect } from './react/features/stream-effects/audio-mixer/Au
165 164
 import { createRnnoiseProcessor } from './react/features/stream-effects/rnnoise';
166 165
 import { handleToggleVideoMuted } from './react/features/toolbox/actions.any';
167 166
 import { muteLocal } from './react/features/video-menu/actions.any';
168
-import UIEvents from './service/UI/UIEvents';
169 167
 
170 168
 const logger = Logger.getLogger(__filename);
171 169
 
172
-const eventEmitter = new EventEmitter();
173
-
174 170
 let room;
175 171
 
176 172
 /*
@@ -1916,21 +1912,12 @@ export default {
1916 1912
             JitsiE2ePingEvents.E2E_RTT_CHANGED,
1917 1913
             (...args) => APP.store.dispatch(e2eRttChanged(...args)));
1918 1914
 
1919
-        APP.UI.addListener(UIEvents.AUDIO_MUTED, muted => {
1920
-            this.muteAudio(muted);
1921
-        });
1922
-        APP.UI.addListener(UIEvents.VIDEO_MUTED, (muted, showUI = false) => {
1923
-            this.muteVideo(muted, showUI);
1924
-        });
1925
-
1926 1915
         room.addCommandListener(this.commands.defaults.ETHERPAD,
1927 1916
             ({ value }) => {
1928 1917
                 APP.UI.initEtherpad(value);
1929 1918
             }
1930 1919
         );
1931 1920
 
1932
-        APP.UI.addListener(UIEvents.EMAIL_CHANGED,
1933
-            this.changeLocalEmail.bind(this));
1934 1921
         room.addCommandListener(this.commands.defaults.EMAIL, (data, from) => {
1935 1922
             APP.store.dispatch(participantUpdated({
1936 1923
                 conference: room,
@@ -1950,9 +1937,6 @@ export default {
1950 1937
                     }));
1951 1938
             });
1952 1939
 
1953
-        APP.UI.addListener(UIEvents.NICKNAME_CHANGED,
1954
-            this.changeLocalDisplayName.bind(this));
1955
-
1956 1940
         room.on(
1957 1941
             JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
1958 1942
             ({ audio, video }) => {
@@ -2007,113 +1991,117 @@ export default {
2007 1991
                 }, NOTIFICATION_TIMEOUT_TYPE.STICKY));
2008 1992
             }
2009 1993
         );
1994
+    },
2010 1995
 
2011
-        // call hangup
2012
-        APP.UI.addListener(UIEvents.HANGUP, () => {
2013
-            this.hangup(true);
2014
-        });
2015
-
2016
-        APP.UI.addListener(
2017
-            UIEvents.VIDEO_DEVICE_CHANGED,
2018
-            cameraDeviceId => {
2019
-                const videoWasMuted = this.isLocalVideoMuted();
2020
-                const localVideoTrack = getLocalJitsiVideoTrack(APP.store.getState());
1996
+    /**
1997
+     * Handles audio device changes.
1998
+     *
1999
+     * @param {string} cameraDeviceId - The new device id.
2000
+     * @returns {Promise}
2001
+     */
2002
+    async onAudioDeviceChanged(micDeviceId) {
2003
+        const audioWasMuted = this.isLocalAudioMuted();
2004
+
2005
+        // Disable noise suppression if it was enabled on the previous track.
2006
+        await APP.store.dispatch(setNoiseSuppressionEnabled(false));
2007
+
2008
+        // When the 'default' mic needs to be selected, we need to pass the real device id to gUM instead of
2009
+        // 'default' in order to get the correct MediaStreamTrack from chrome because of the following bug.
2010
+        // https://bugs.chromium.org/p/chromium/issues/detail?id=997689.
2011
+        const isDefaultMicSelected = micDeviceId === 'default';
2012
+        const selectedDeviceId = isDefaultMicSelected
2013
+            ? getDefaultDeviceId(APP.store.getState(), 'audioInput')
2014
+            : micDeviceId;
2015
+
2016
+        logger.info(`Switching audio input device to ${selectedDeviceId}`);
2017
+        sendAnalytics(createDeviceChangedEvent('audio', 'input'));
2018
+        createLocalTracksF({
2019
+            devices: [ 'audio' ],
2020
+            micDeviceId: selectedDeviceId
2021
+        })
2022
+        .then(([ stream ]) => {
2023
+            // if audio was muted before changing the device, mute
2024
+            // with the new device
2025
+            if (audioWasMuted) {
2026
+                return stream.mute()
2027
+                    .then(() => stream);
2028
+            }
2021 2029
 
2022
-                if (localVideoTrack?.getDeviceId() === cameraDeviceId) {
2023
-                    return;
2024
-                }
2030
+            return stream;
2031
+        })
2032
+        .then(async stream => {
2033
+            await this._maybeApplyAudioMixerEffect(stream);
2025 2034
 
2026
-                sendAnalytics(createDeviceChangedEvent('video', 'input'));
2035
+            return this.useAudioStream(stream);
2036
+        })
2037
+        .then(() => {
2038
+            const localAudio = getLocalJitsiAudioTrack(APP.store.getState());
2027 2039
 
2028
-                createLocalTracksF({
2029
-                    devices: [ 'video' ],
2030
-                    cameraDeviceId
2031
-                })
2032
-                .then(([ stream ]) => {
2033
-                    // if we are in audio only mode or video was muted before
2034
-                    // changing device, then mute
2035
-                    if (this.isAudioOnly() || videoWasMuted) {
2036
-                        return stream.mute()
2037
-                            .then(() => stream);
2038
-                    }
2040
+            if (localAudio && isDefaultMicSelected) {
2041
+                // workaround for the default device to be shown as selected in the
2042
+                // settings even when the real device id was passed to gUM because of the
2043
+                // above mentioned chrome bug.
2044
+                localAudio._realDeviceId = localAudio.deviceId = 'default';
2045
+            }
2046
+        })
2047
+        .catch(err => {
2048
+            logger.error(`Failed to switch to selected audio input device ${selectedDeviceId}, error=${err}`);
2049
+            APP.store.dispatch(notifyMicError(err));
2050
+        });
2051
+    },
2039 2052
 
2040
-                    return stream;
2041
-                })
2042
-                .then(stream => {
2043
-                    logger.info(`Switching the local video device to ${cameraDeviceId}.`);
2053
+    /**
2054
+     * Handles video device changes.
2055
+     *
2056
+     * @param {string} cameraDeviceId - The new device id.
2057
+     * @returns {void}
2058
+     */
2059
+    onVideoDeviceChanged(cameraDeviceId) {
2060
+        const videoWasMuted = this.isLocalVideoMuted();
2061
+        const localVideoTrack = getLocalJitsiVideoTrack(APP.store.getState());
2044 2062
 
2045
-                    return this.useVideoStream(stream);
2046
-                })
2047
-                .catch(error => {
2048
-                    logger.error(`Failed to switch to selected camera:${cameraDeviceId}, error:${error}`);
2063
+        if (localVideoTrack?.getDeviceId() === cameraDeviceId) {
2064
+            return;
2065
+        }
2049 2066
 
2050
-                    return APP.store.dispatch(notifyCameraError(error));
2051
-                });
2067
+        sendAnalytics(createDeviceChangedEvent('video', 'input'));
2068
+
2069
+        createLocalTracksF({
2070
+            devices: [ 'video' ],
2071
+            cameraDeviceId
2072
+        })
2073
+        .then(([ stream ]) => {
2074
+            // if we are in audio only mode or video was muted before
2075
+            // changing device, then mute
2076
+            if (this.isAudioOnly() || videoWasMuted) {
2077
+                return stream.mute()
2078
+                    .then(() => stream);
2052 2079
             }
2053
-        );
2054 2080
 
2055
-        APP.UI.addListener(
2056
-            UIEvents.AUDIO_DEVICE_CHANGED,
2057
-            async micDeviceId => {
2058
-                const audioWasMuted = this.isLocalAudioMuted();
2059
-
2060
-                // Disable noise suppression if it was enabled on the previous track.
2061
-                await APP.store.dispatch(setNoiseSuppressionEnabled(false));
2062
-
2063
-                // When the 'default' mic needs to be selected, we need to pass the real device id to gUM instead of
2064
-                // 'default' in order to get the correct MediaStreamTrack from chrome because of the following bug.
2065
-                // https://bugs.chromium.org/p/chromium/issues/detail?id=997689.
2066
-                const isDefaultMicSelected = micDeviceId === 'default';
2067
-                const selectedDeviceId = isDefaultMicSelected
2068
-                    ? getDefaultDeviceId(APP.store.getState(), 'audioInput')
2069
-                    : micDeviceId;
2070
-
2071
-                logger.info(`Switching audio input device to ${selectedDeviceId}`);
2072
-                sendAnalytics(createDeviceChangedEvent('audio', 'input'));
2073
-                createLocalTracksF({
2074
-                    devices: [ 'audio' ],
2075
-                    micDeviceId: selectedDeviceId
2076
-                })
2077
-                .then(([ stream ]) => {
2078
-                    // if audio was muted before changing the device, mute
2079
-                    // with the new device
2080
-                    if (audioWasMuted) {
2081
-                        return stream.mute()
2082
-                            .then(() => stream);
2083
-                    }
2081
+            return stream;
2082
+        })
2083
+        .then(stream => {
2084
+            logger.info(`Switching the local video device to ${cameraDeviceId}.`);
2084 2085
 
2085
-                    return stream;
2086
-                })
2087
-                .then(async stream => {
2088
-                    await this._maybeApplyAudioMixerEffect(stream);
2086
+            return this.useVideoStream(stream);
2087
+        })
2088
+        .catch(error => {
2089
+            logger.error(`Failed to switch to selected camera:${cameraDeviceId}, error:${error}`);
2089 2090
 
2090
-                    return this.useAudioStream(stream);
2091
-                })
2092
-                .then(() => {
2093
-                    const localAudio = getLocalJitsiAudioTrack(APP.store.getState());
2094
-
2095
-                    if (localAudio && isDefaultMicSelected) {
2096
-                        // workaround for the default device to be shown as selected in the
2097
-                        // settings even when the real device id was passed to gUM because of the
2098
-                        // above mentioned chrome bug.
2099
-                        localAudio._realDeviceId = localAudio.deviceId = 'default';
2100
-                    }
2101
-                })
2102
-                .catch(err => {
2103
-                    logger.error(`Failed to switch to selected audio input device ${selectedDeviceId}, error=${err}`);
2104
-                    APP.store.dispatch(notifyMicError(err));
2105
-                });
2106
-            }
2107
-        );
2091
+            return APP.store.dispatch(notifyCameraError(error));
2092
+        });
2093
+    },
2108 2094
 
2109
-        APP.UI.addListener(UIEvents.TOGGLE_AUDIO_ONLY, () => {
2110
-            // Immediately update the UI by having remote videos and the large video update themselves.
2111
-            const displayedUserId = APP.UI.getLargeVideoID();
2095
+    /**
2096
+     * Handles audio only changes.
2097
+     */
2098
+    onToggleAudioOnly() {
2099
+        // Immediately update the UI by having remote videos and the large video update themselves.
2100
+        const displayedUserId = APP.UI.getLargeVideoID();
2112 2101
 
2113
-            if (displayedUserId) {
2114
-                APP.UI.updateLargeVideo(displayedUserId, true);
2115
-            }
2116
-        });
2102
+        if (displayedUserId) {
2103
+            APP.UI.updateLargeVideo(displayedUserId, true);
2104
+        }
2117 2105
     },
2118 2106
 
2119 2107
     /**
@@ -2408,8 +2396,6 @@ export default {
2408 2396
                 this.deviceChangeListener);
2409 2397
         }
2410 2398
 
2411
-        APP.UI.removeAllListeners();
2412
-
2413 2399
         let feedbackResultPromise = Promise.resolve({});
2414 2400
 
2415 2401
         if (requestFeedback) {
@@ -2516,37 +2502,6 @@ export default {
2516 2502
         room.sendEndpointMessage(to, payload);
2517 2503
     },
2518 2504
 
2519
-    /**
2520
-     * Adds new listener.
2521
-     * @param {String} eventName the name of the event
2522
-     * @param {Function} listener the listener.
2523
-     */
2524
-    addListener(eventName, listener) {
2525
-        eventEmitter.addListener(eventName, listener);
2526
-    },
2527
-
2528
-    /**
2529
-     * Removes listener.
2530
-     * @param {String} eventName the name of the event that triggers the
2531
-     * listener
2532
-     * @param {Function} listener the listener.
2533
-     */
2534
-    removeListener(eventName, listener) {
2535
-        eventEmitter.removeListener(eventName, listener);
2536
-    },
2537
-
2538
-    /**
2539
-     * Changes the display name for the local user
2540
-     * @param nickname {string} the new display name
2541
-     */
2542
-    changeLocalDisplayName(nickname = '') {
2543
-        const formattedNickname = getNormalizedDisplayName(nickname);
2544
-
2545
-        APP.store.dispatch(updateSettings({
2546
-            displayName: formattedNickname
2547
-        }));
2548
-    },
2549
-
2550 2505
     /**
2551 2506
      * Callback invoked by the external api create or update a direct connection
2552 2507
      * from the local client to an external client.

+ 6
- 2
modules/API/API.js Zobrazit soubor

@@ -76,6 +76,7 @@ import { setMediaEncryptionKey, toggleE2EE } from '../../react/features/e2ee/act
76 76
 import {
77 77
     addStageParticipant,
78 78
     resizeFilmStrip,
79
+    setFilmstripVisible,
79 80
     setVolume,
80 81
     togglePinStageParticipant
81 82
 } from '../../react/features/filmstrip/actions.web';
@@ -104,6 +105,7 @@ import { startAudioScreenShareFlow, startScreenShareFlow } from '../../react/fea
104 105
 import { isScreenAudioSupported } from '../../react/features/screen-share/functions';
105 106
 import { toggleScreenshotCaptureSummary } from '../../react/features/screenshot-capture/actions';
106 107
 import { isScreenshotCaptureEnabled } from '../../react/features/screenshot-capture/functions';
108
+import { changeLocalDisplayName } from '../../react/features/settings/actions.web';
107 109
 import SettingsDialog from '../../react/features/settings/components/web/SettingsDialog';
108 110
 import { SETTINGS_TABS } from '../../react/features/settings/constants';
109 111
 import { playSharedVideo, stopSharedVideo } from '../../react/features/shared-video/actions.any';
@@ -199,7 +201,7 @@ function initCommands() {
199 201
         },
200 202
         'display-name': displayName => {
201 203
             sendAnalytics(createApiEvent('display.name.changed'));
202
-            APP.conference.changeLocalDisplayName(displayName);
204
+            APP.store.dispatch(changeLocalDisplayName(displayName));
203 205
         },
204 206
         'local-subject': localSubject => {
205 207
             sendAnalytics(createApiEvent('local.subject.changed'));
@@ -376,7 +378,9 @@ function initCommands() {
376 378
         },
377 379
         'toggle-film-strip': () => {
378 380
             sendAnalytics(createApiEvent('film.strip.toggled'));
379
-            APP.UI.toggleFilmstrip();
381
+            const { visible } = APP.store.getState()['features/filmstrip'];
382
+
383
+            APP.store.dispatch(setFilmstripVisible(!visible));
380 384
         },
381 385
 
382 386
         /*

+ 5
- 57
modules/UI/UI.js Zobrazit soubor

@@ -4,7 +4,6 @@
4 4
 const UI = {};
5 5
 
6 6
 import Logger from '@jitsi/logger';
7
-import EventEmitter from 'events';
8 7
 
9 8
 import {
10 9
     conferenceWillInit
@@ -13,7 +12,6 @@ import { isMobileBrowser } from '../../react/features/base/environment/utils';
13 12
 import { setColorAlpha } from '../../react/features/base/util/helpers';
14 13
 import { sanitizeUrl } from '../../react/features/base/util/uri';
15 14
 import { setDocumentUrl } from '../../react/features/etherpad/actions';
16
-import { setFilmstripVisible } from '../../react/features/filmstrip/actions.any';
17 15
 import {
18 16
     setNotificationsEnabled,
19 17
     showNotification
@@ -25,7 +23,6 @@ import {
25 23
     setToolboxEnabled,
26 24
     showToolbox
27 25
 } from '../../react/features/toolbox/actions.web';
28
-import UIEvents from '../../service/UI/UIEvents';
29 26
 
30 27
 import EtherpadManager from './etherpad/Etherpad';
31 28
 import UIUtil from './util/UIUtil';
@@ -33,22 +30,8 @@ import VideoLayout from './videolayout/VideoLayout';
33 30
 
34 31
 const logger = Logger.getLogger(__filename);
35 32
 
36
-const eventEmitter = new EventEmitter();
37
-
38
-UI.eventEmitter = eventEmitter;
39
-
40 33
 let etherpadManager;
41 34
 
42
-const UIListeners = new Map([
43
-    [
44
-        UIEvents.ETHERPAD_CLICKED,
45
-        () => etherpadManager && etherpadManager.toggleEtherpad()
46
-    ], [
47
-        UIEvents.TOGGLE_FILMSTRIP,
48
-        () => UI.toggleFilmstrip()
49
-    ]
50
-]);
51
-
52 35
 /**
53 36
  * Indicates if we're currently in full screen mode.
54 37
  *
@@ -96,10 +79,11 @@ UI.start = function() {
96 79
 };
97 80
 
98 81
 /**
99
- * Setup some UI event listeners.
82
+ * Handles etherpad click.
100 83
  */
101
-UI.registerListeners
102
-    = () => UIListeners.forEach((value, key) => UI.addListener(key, value));
84
+UI.onEtherpadClicked = function() {
85
+    etherpadManager && etherpadManager.toggleEtherpad();
86
+};
103 87
 
104 88
 /**
105 89
  *
@@ -143,7 +127,7 @@ UI.initEtherpad = name => {
143 127
     }
144 128
     logger.log('Etherpad is enabled');
145 129
 
146
-    etherpadManager = new EtherpadManager(eventEmitter);
130
+    etherpadManager = new EtherpadManager();
147 131
 
148 132
     const url = new URL(name, etherpadBaseUrl);
149 133
 
@@ -197,15 +181,6 @@ UI.updateUserStatus = (user, status) => {
197 181
     }, NOTIFICATION_TIMEOUT_TYPE.SHORT));
198 182
 };
199 183
 
200
-/**
201
- * Toggles filmstrip.
202
- */
203
-UI.toggleFilmstrip = function() {
204
-    const { visible } = APP.store.getState()['features/filmstrip'];
205
-
206
-    APP.store.dispatch(setFilmstripVisible(!visible));
207
-};
208
-
209 184
 /**
210 185
  * Sets muted video state for participant
211 186
  */
@@ -219,33 +194,6 @@ UI.setVideoMuted = function(id) {
219 194
 
220 195
 UI.updateLargeVideo = (id, forceUpdate) => VideoLayout.updateLargeVideo(id, forceUpdate);
221 196
 
222
-/**
223
- * Adds a listener that would be notified on the given type of event.
224
- *
225
- * @param type the type of the event we're listening for
226
- * @param listener a function that would be called when notified
227
- */
228
-UI.addListener = function(type, listener) {
229
-    eventEmitter.on(type, listener);
230
-};
231
-
232
-/**
233
- * Removes the all listeners for all events.
234
- *
235
- * @returns {void}
236
- */
237
-UI.removeAllListeners = function() {
238
-    eventEmitter.removeAllListeners();
239
-};
240
-
241
-/**
242
- * Emits the event of given type by specifying the parameters in options.
243
- *
244
- * @param type the type of the event we're emitting
245
- * @param options the parameters for the event
246
- */
247
-UI.emitEvent = (type, ...options) => eventEmitter.emit(type, ...options);
248
-
249 197
 // Used by torture.
250 198
 UI.showToolbar = timeout => APP.store.dispatch(showToolbox(timeout));
251 199
 

+ 1
- 2
modules/UI/etherpad/Etherpad.js Zobrazit soubor

@@ -138,8 +138,7 @@ export default class EtherpadManager {
138 138
     /**
139 139
      *
140 140
      */
141
-    constructor(eventEmitter) {
142
-        this.eventEmitter = eventEmitter;
141
+    constructor() {
143 142
         this.etherpad = null;
144 143
     }
145 144
 

+ 1
- 3
react/features/base/audio-only/actions.ts Zobrazit soubor

@@ -1,5 +1,3 @@
1
-// @ts-expect-error
2
-import UIEvents from '../../../../service/UI/UIEvents';
3 1
 import { createAudioOnlyChangedEvent } from '../../analytics/AnalyticsEvents';
4 2
 import { sendAnalytics } from '../../analytics/functions';
5 3
 import { IStore } from '../../app/types';
@@ -33,7 +31,7 @@ export function setAudioOnly(audioOnly: boolean) {
33 31
             if (typeof APP !== 'undefined') {
34 32
                 // TODO This should be a temporary solution that lasts only until video
35 33
                 // tracks and all ui is moved into react/redux on the web.
36
-                APP.UI.emitEvent(UIEvents.TOGGLE_AUDIO_ONLY, audioOnly);
34
+                APP.conference.onToggleAudioOnly();
37 35
             }
38 36
         }
39 37
     };

+ 2
- 4
react/features/base/conference/actions.ts Zobrazit soubor

@@ -1,5 +1,3 @@
1
-// @ts-expect-error
2
-import UIEvents from '../../../../service/UI/UIEvents';
3 1
 import { createStartMutedConfigurationEvent } from '../../analytics/AnalyticsEvents';
4 2
 import { sendAnalytics } from '../../analytics/functions';
5 3
 import { IReduxState, IStore } from '../../app/types';
@@ -1083,7 +1081,7 @@ export function redirect(vnode: string, focusJid: string, username: string) {
1083 1081
                                 dispatch(setAudioMuted(false, true));
1084 1082
 
1085 1083
                                 // // FIXME: The old conference logic still relies on this event being emitted.
1086
-                                typeof APP === 'undefined' || APP.UI.emitEvent(UIEvents.AUDIO_MUTED, false);
1084
+                                typeof APP === 'undefined' || APP.conference.muteAudio(false);
1087 1085
                             }
1088 1086
                         }
1089 1087
 
@@ -1096,7 +1094,7 @@ export function redirect(vnode: string, focusJid: string, username: string) {
1096 1094
                                 dispatch(setVideoMuted(false, VIDEO_MUTISM_AUTHORITY.USER, true));
1097 1095
 
1098 1096
                                 // // FIXME: The old conference logic still relies on this event being emitted.
1099
-                                typeof APP === 'undefined' || APP.UI.emitEvent(UIEvents.VIDEO_MUTED, false);
1097
+                                typeof APP === 'undefined' || APP.conference.muteVideo(false, false);
1100 1098
                             }
1101 1099
                         }
1102 1100
                     }

+ 2
- 4
react/features/base/devices/middleware.web.ts Zobrazit soubor

@@ -1,7 +1,5 @@
1 1
 import { AnyAction } from 'redux';
2 2
 
3
-// @ts-expect-error
4
-import UIEvents from '../../../../service/UI/UIEvents';
5 3
 import { IStore } from '../../app/types';
6 4
 import { processExternalDeviceRequest } from '../../device-selection/functions';
7 5
 import { showNotification, showWarningNotification } from '../../notifications/actions';
@@ -161,7 +159,7 @@ MiddlewareRegistry.register(store => next => action => {
161 159
         if (isPrejoinPageVisible(store.getState())) {
162 160
             store.dispatch(replaceAudioTrackById(action.deviceId));
163 161
         } else {
164
-            APP.UI.emitEvent(UIEvents.AUDIO_DEVICE_CHANGED, action.deviceId);
162
+            APP.conference.onAudioDeviceChanged(action.deviceId);
165 163
         }
166 164
         break;
167 165
     case SET_VIDEO_INPUT_DEVICE: {
@@ -174,7 +172,7 @@ MiddlewareRegistry.register(store => next => action => {
174 172
         if (isPrejoinPageVisible(store.getState())) {
175 173
             store.dispatch(replaceVideoTrackById(action.deviceId));
176 174
         } else {
177
-            APP.UI.emitEvent(UIEvents.VIDEO_DEVICE_CHANGED, action.deviceId);
175
+            APP.conference.onVideoDeviceChanged(action.deviceId);
178 176
         }
179 177
         break;
180 178
     }

+ 2
- 3
react/features/base/participants/middleware.ts Zobrazit soubor

@@ -2,8 +2,6 @@ import i18n from 'i18next';
2 2
 import { batch } from 'react-redux';
3 3
 import { AnyAction } from 'redux';
4 4
 
5
-// @ts-expect-error
6
-import UIEvents from '../../../../service/UI/UIEvents';
7 5
 import { IStore } from '../../app/types';
8 6
 import { approveParticipant } from '../../av-moderation/actions';
9 7
 import { UPDATE_BREAKOUT_ROOMS } from '../../breakout-rooms/actionTypes';
@@ -20,6 +18,7 @@ import { isForceMuted } from '../../participants-pane/functions';
20 18
 import { CALLING, INVITED } from '../../presence-status/constants';
21 19
 import { RAISE_HAND_SOUND_ID } from '../../reactions/constants';
22 20
 import { RECORDING_OFF_SOUND_ID, RECORDING_ON_SOUND_ID } from '../../recording/constants';
21
+import { changeLocalDisplayName } from '../../settings/actions';
23 22
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app/actionTypes';
24 23
 import { CONFERENCE_WILL_JOIN } from '../conference/actionTypes';
25 24
 import { forEachConference, getCurrentConference } from '../conference/functions';
@@ -241,7 +240,7 @@ MiddlewareRegistry.register(store => next => action => {
241 240
             const participant = getLocalParticipant(store.getState());
242 241
 
243 242
             if (participant && participant.id === action.id) {
244
-                APP.UI.emitEvent(UIEvents.NICKNAME_CHANGED, action.name);
243
+                store.dispatch(changeLocalDisplayName(action.name));
245 244
             }
246 245
         }
247 246
 

+ 0
- 2
react/features/conference/components/web/Conference.tsx Zobrazit soubor

@@ -368,8 +368,6 @@ class Conference extends AbstractConference<IProps, any> {
368 368
      */
369 369
     _start() {
370 370
         APP.UI.start();
371
-
372
-        APP.UI.registerListeners();
373 371
         APP.UI.bindEvents();
374 372
 
375 373
         FULL_SCREEN_EVENTS.forEach(name =>

+ 1
- 3
react/features/etherpad/middleware.ts Zobrazit soubor

@@ -1,5 +1,3 @@
1
-// @ts-expect-error
2
-import UIEvents from '../../../service/UI/UIEvents';
3 1
 import { CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes';
4 2
 import { getCurrentConference } from '../base/conference/functions';
5 3
 import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
@@ -41,7 +39,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
41 39
     }
42 40
     case TOGGLE_DOCUMENT_EDITING: {
43 41
         if (typeof APP !== 'undefined') {
44
-            APP.UI.emitEvent(UIEvents.ETHERPAD_CLICKED);
42
+            APP.UI.onEtherpadClicked();
45 43
         }
46 44
         break;
47 45
     }

+ 0
- 8
react/features/room-lock/middleware.ts Zobrazit soubor

@@ -1,7 +1,5 @@
1 1
 import { AnyAction } from 'redux';
2 2
 
3
-// @ts-expect-error
4
-import UIEvents from '../../../service/UI/UIEvents';
5 3
 import { IStore } from '../app/types';
6 4
 import {
7 5
     CONFERENCE_FAILED,
@@ -36,12 +34,6 @@ MiddlewareRegistry.register(store => next => action => {
36 34
         return _conferenceJoined(store, next, action);
37 35
 
38 36
     case LOCK_STATE_CHANGED: {
39
-        // TODO Remove this logic when all components interested in the lock
40
-        // state change event are moved into react/redux.
41
-        if (typeof APP !== 'undefined') {
42
-            APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK, action.locked);
43
-        }
44
-
45 37
         const previousLockedState = store.getState()['features/base/conference'].locked;
46 38
 
47 39
         const result = next(action);

+ 13
- 0
react/features/settings/actions.native.ts Zobrazit soubor

@@ -36,3 +36,16 @@ export function openLogoutDialog() {
36 36
         }));
37 37
     };
38 38
 }
39
+
40
+/**
41
+* Changes the display name for the local user.
42
+*
43
+* @param {string} _nickname - The new display name.
44
+* @returns {Function}
45
+*/
46
+export function changeLocalDisplayName(_nickname = '') {
47
+    // not used on mobile.
48
+    return (_dispatch: IStore['dispatch'], _getState: IStore['getState']) => {
49
+        // no-op action.
50
+    };
51
+}

+ 16
- 1
react/features/settings/actions.web.ts Zobrazit soubor

@@ -12,6 +12,7 @@ import { hangup } from '../base/connection/actions.web';
12 12
 import { openDialog } from '../base/dialog/actions';
13 13
 import i18next from '../base/i18n/i18next';
14 14
 import { browser } from '../base/lib-jitsi-meet';
15
+import { getNormalizedDisplayName } from '../base/participants/functions';
15 16
 import { updateSettings } from '../base/settings/actions';
16 17
 import { getLocalVideoTrack } from '../base/tracks/functions.web';
17 18
 import { appendURLHashParam } from '../base/util/uri';
@@ -191,7 +192,7 @@ export function submitProfileTab(newState: any) {
191 192
         const currentState = getProfileTabProps(getState());
192 193
 
193 194
         if (newState.displayName !== currentState.displayName) {
194
-            APP.conference.changeLocalDisplayName(newState.displayName);
195
+            dispatch(changeLocalDisplayName(newState.displayName));
195 196
         }
196 197
 
197 198
         if (newState.email !== currentState.email) {
@@ -200,6 +201,20 @@ export function submitProfileTab(newState: any) {
200 201
     };
201 202
 }
202 203
 
204
+/**
205
+* Changes the display name for the local user.
206
+*
207
+* @param {string} nickname - The new display name.
208
+* @returns {Function}
209
+*/
210
+export function changeLocalDisplayName(nickname = '') {
211
+    return (dispatch: IStore['dispatch']) => {
212
+        const formattedNickname = getNormalizedDisplayName(nickname);
213
+
214
+        dispatch(updateSettings({ displayName: formattedNickname }));
215
+    };
216
+}
217
+
203 218
 /**
204 219
  * Submits the settings from the "Sounds" tab of the settings dialog.
205 220
  *

+ 1
- 3
react/features/toolbox/actions.any.ts Zobrazit soubor

@@ -1,5 +1,3 @@
1
-// @ts-expect-error
2
-import UIEvents from '../../../service/UI/UIEvents';
3 1
 import { VIDEO_MUTE, createToolbarEvent } from '../analytics/AnalyticsEvents';
4 2
 import { sendAnalytics } from '../analytics/functions';
5 3
 import { IStore } from '../app/types';
@@ -103,7 +101,7 @@ export function handleToggleVideoMuted(muted: boolean, showUI: boolean, ensureTr
103 101
         // FIXME: The old conference logic still relies on this event being
104 102
         // emitted.
105 103
         typeof APP === 'undefined'
106
-            || APP.UI.emitEvent(UIEvents.VIDEO_MUTED, muted, showUI);
104
+            || APP.conference.muteVideo(muted, showUI);
107 105
 
108 106
     };
109 107
 }

+ 3
- 4
react/features/video-menu/actions.any.ts Zobrazit soubor

@@ -1,5 +1,3 @@
1
-// @ts-expect-error
2
-import UIEvents from '../../../service/UI/UIEvents';
3 1
 import {
4 2
     AUDIO_MUTE,
5 3
     VIDEO_MUTE,
@@ -55,8 +53,9 @@ export function muteLocal(enable: boolean, mediaType: MediaType, stopScreenShari
55 53
             : setVideoMuted(enable, VIDEO_MUTISM_AUTHORITY.USER, /* ensureTrack */ true));
56 54
 
57 55
         // FIXME: The old conference logic still relies on this event being emitted.
58
-        typeof APP === 'undefined'
59
-            || APP.UI.emitEvent(isAudio ? UIEvents.AUDIO_MUTED : UIEvents.VIDEO_MUTED, enable);
56
+        if (typeof APP !== 'undefined') {
57
+            isAudio ? APP.conference.muteAudio(enable) : APP.conference.muteVideo(enable, false);
58
+        }
60 59
     };
61 60
 }
62 61
 

+ 0
- 57
service/UI/UIEvents.js Zobrazit soubor

@@ -1,57 +0,0 @@
1
-export default {
2
-    NICKNAME_CHANGED: 'UI.nickname_changed',
3
-
4
-    /**
5
-     * Notifies that local user changed email.
6
-     */
7
-    EMAIL_CHANGED: 'UI.email_changed',
8
-
9
-    /**
10
-     * Notifies that "start muted" settings changed.
11
-     */
12
-    AUDIO_MUTED: 'UI.audio_muted',
13
-    VIDEO_MUTED: 'UI.video_muted',
14
-    ETHERPAD_CLICKED: 'UI.etherpad_clicked',
15
-
16
-    /**
17
-     * Updates shared video with params: url, state, time(optional)
18
-     * Where url is the video link, state is stop/start/pause and time is the
19
-     * current video playing time.
20
-     */
21
-    TOGGLE_FULLSCREEN: 'UI.toogle_fullscreen',
22
-    FULLSCREEN_TOGGLED: 'UI.fullscreen_toggled',
23
-
24
-    /**
25
-     * Notifies that the audio only mode was toggled.
26
-     */
27
-    TOGGLE_AUDIO_ONLY: 'UI.toggle_audioonly',
28
-
29
-    /**
30
-     * Notifies that a command to toggle the filmstrip has been issued. The
31
-     * event may optionally specify a {Boolean} (primitive) value to assign to
32
-     * the visibility of the filmstrip (i.e. the event may act as a setter).
33
-     * The very toggling of the filmstrip may or may not occurred at the time
34
-     * of the receipt of the event depending on the position of the receiving
35
-     * event listener in relation to the event listener which carries out the
36
-     * command to toggle the filmstrip.
37
-     *
38
-     * @see {TOGGLED_FILMSTRIP}
39
-     */
40
-    TOGGLE_FILMSTRIP: 'UI.toggle_filmstrip',
41
-
42
-    HANGUP: 'UI.hangup',
43
-    VIDEO_DEVICE_CHANGED: 'UI.video_device_changed',
44
-    AUDIO_DEVICE_CHANGED: 'UI.audio_device_changed',
45
-
46
-    /**
47
-     * Notifies that the side toolbar container has been toggled. The actual
48
-     * event must contain the identifier of the container that has been toggled
49
-     * and information about toggle on or off.
50
-     */
51
-    SIDE_TOOLBAR_CONTAINER_TOGGLED: 'UI.side_container_toggled',
52
-
53
-    /**
54
-     * Notifies that the raise hand has been changed.
55
-     */
56
-    LOCAL_RAISE_HAND_CHANGED: 'UI.local_raise_hand_changed'
57
-};

Načítá se…
Zrušit
Uložit