浏览代码

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 1年前
父节点
当前提交
9bb27b83d9

+ 98
- 143
conference.js 查看文件

2
 
2
 
3
 import { jitsiLocalStorage } from '@jitsi/js-utils';
3
 import { jitsiLocalStorage } from '@jitsi/js-utils';
4
 import Logger from '@jitsi/logger';
4
 import Logger from '@jitsi/logger';
5
-import EventEmitter from 'events';
6
 
5
 
7
 import { ENDPOINT_TEXT_MESSAGE_NAME } from './modules/API/constants';
6
 import { ENDPOINT_TEXT_MESSAGE_NAME } from './modules/API/constants';
8
 import { AUDIO_ONLY_SCREEN_SHARE_NO_TRACK } from './modules/UI/UIErrors';
7
 import { AUDIO_ONLY_SCREEN_SHARE_NO_TRACK } from './modules/UI/UIErrors';
165
 import { createRnnoiseProcessor } from './react/features/stream-effects/rnnoise';
164
 import { createRnnoiseProcessor } from './react/features/stream-effects/rnnoise';
166
 import { handleToggleVideoMuted } from './react/features/toolbox/actions.any';
165
 import { handleToggleVideoMuted } from './react/features/toolbox/actions.any';
167
 import { muteLocal } from './react/features/video-menu/actions.any';
166
 import { muteLocal } from './react/features/video-menu/actions.any';
168
-import UIEvents from './service/UI/UIEvents';
169
 
167
 
170
 const logger = Logger.getLogger(__filename);
168
 const logger = Logger.getLogger(__filename);
171
 
169
 
172
-const eventEmitter = new EventEmitter();
173
-
174
 let room;
170
 let room;
175
 
171
 
176
 /*
172
 /*
1916
             JitsiE2ePingEvents.E2E_RTT_CHANGED,
1912
             JitsiE2ePingEvents.E2E_RTT_CHANGED,
1917
             (...args) => APP.store.dispatch(e2eRttChanged(...args)));
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
         room.addCommandListener(this.commands.defaults.ETHERPAD,
1915
         room.addCommandListener(this.commands.defaults.ETHERPAD,
1927
             ({ value }) => {
1916
             ({ value }) => {
1928
                 APP.UI.initEtherpad(value);
1917
                 APP.UI.initEtherpad(value);
1929
             }
1918
             }
1930
         );
1919
         );
1931
 
1920
 
1932
-        APP.UI.addListener(UIEvents.EMAIL_CHANGED,
1933
-            this.changeLocalEmail.bind(this));
1934
         room.addCommandListener(this.commands.defaults.EMAIL, (data, from) => {
1921
         room.addCommandListener(this.commands.defaults.EMAIL, (data, from) => {
1935
             APP.store.dispatch(participantUpdated({
1922
             APP.store.dispatch(participantUpdated({
1936
                 conference: room,
1923
                 conference: room,
1950
                     }));
1937
                     }));
1951
             });
1938
             });
1952
 
1939
 
1953
-        APP.UI.addListener(UIEvents.NICKNAME_CHANGED,
1954
-            this.changeLocalDisplayName.bind(this));
1955
-
1956
         room.on(
1940
         room.on(
1957
             JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
1941
             JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
1958
             ({ audio, video }) => {
1942
             ({ audio, video }) => {
2007
                 }, NOTIFICATION_TIMEOUT_TYPE.STICKY));
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
                 this.deviceChangeListener);
2396
                 this.deviceChangeListener);
2409
         }
2397
         }
2410
 
2398
 
2411
-        APP.UI.removeAllListeners();
2412
-
2413
         let feedbackResultPromise = Promise.resolve({});
2399
         let feedbackResultPromise = Promise.resolve({});
2414
 
2400
 
2415
         if (requestFeedback) {
2401
         if (requestFeedback) {
2516
         room.sendEndpointMessage(to, payload);
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
      * Callback invoked by the external api create or update a direct connection
2506
      * Callback invoked by the external api create or update a direct connection
2552
      * from the local client to an external client.
2507
      * from the local client to an external client.

+ 6
- 2
modules/API/API.js 查看文件

76
 import {
76
 import {
77
     addStageParticipant,
77
     addStageParticipant,
78
     resizeFilmStrip,
78
     resizeFilmStrip,
79
+    setFilmstripVisible,
79
     setVolume,
80
     setVolume,
80
     togglePinStageParticipant
81
     togglePinStageParticipant
81
 } from '../../react/features/filmstrip/actions.web';
82
 } from '../../react/features/filmstrip/actions.web';
104
 import { isScreenAudioSupported } from '../../react/features/screen-share/functions';
105
 import { isScreenAudioSupported } from '../../react/features/screen-share/functions';
105
 import { toggleScreenshotCaptureSummary } from '../../react/features/screenshot-capture/actions';
106
 import { toggleScreenshotCaptureSummary } from '../../react/features/screenshot-capture/actions';
106
 import { isScreenshotCaptureEnabled } from '../../react/features/screenshot-capture/functions';
107
 import { isScreenshotCaptureEnabled } from '../../react/features/screenshot-capture/functions';
108
+import { changeLocalDisplayName } from '../../react/features/settings/actions.web';
107
 import SettingsDialog from '../../react/features/settings/components/web/SettingsDialog';
109
 import SettingsDialog from '../../react/features/settings/components/web/SettingsDialog';
108
 import { SETTINGS_TABS } from '../../react/features/settings/constants';
110
 import { SETTINGS_TABS } from '../../react/features/settings/constants';
109
 import { playSharedVideo, stopSharedVideo } from '../../react/features/shared-video/actions.any';
111
 import { playSharedVideo, stopSharedVideo } from '../../react/features/shared-video/actions.any';
199
         },
201
         },
200
         'display-name': displayName => {
202
         'display-name': displayName => {
201
             sendAnalytics(createApiEvent('display.name.changed'));
203
             sendAnalytics(createApiEvent('display.name.changed'));
202
-            APP.conference.changeLocalDisplayName(displayName);
204
+            APP.store.dispatch(changeLocalDisplayName(displayName));
203
         },
205
         },
204
         'local-subject': localSubject => {
206
         'local-subject': localSubject => {
205
             sendAnalytics(createApiEvent('local.subject.changed'));
207
             sendAnalytics(createApiEvent('local.subject.changed'));
376
         },
378
         },
377
         'toggle-film-strip': () => {
379
         'toggle-film-strip': () => {
378
             sendAnalytics(createApiEvent('film.strip.toggled'));
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 查看文件

4
 const UI = {};
4
 const UI = {};
5
 
5
 
6
 import Logger from '@jitsi/logger';
6
 import Logger from '@jitsi/logger';
7
-import EventEmitter from 'events';
8
 
7
 
9
 import {
8
 import {
10
     conferenceWillInit
9
     conferenceWillInit
13
 import { setColorAlpha } from '../../react/features/base/util/helpers';
12
 import { setColorAlpha } from '../../react/features/base/util/helpers';
14
 import { sanitizeUrl } from '../../react/features/base/util/uri';
13
 import { sanitizeUrl } from '../../react/features/base/util/uri';
15
 import { setDocumentUrl } from '../../react/features/etherpad/actions';
14
 import { setDocumentUrl } from '../../react/features/etherpad/actions';
16
-import { setFilmstripVisible } from '../../react/features/filmstrip/actions.any';
17
 import {
15
 import {
18
     setNotificationsEnabled,
16
     setNotificationsEnabled,
19
     showNotification
17
     showNotification
25
     setToolboxEnabled,
23
     setToolboxEnabled,
26
     showToolbox
24
     showToolbox
27
 } from '../../react/features/toolbox/actions.web';
25
 } from '../../react/features/toolbox/actions.web';
28
-import UIEvents from '../../service/UI/UIEvents';
29
 
26
 
30
 import EtherpadManager from './etherpad/Etherpad';
27
 import EtherpadManager from './etherpad/Etherpad';
31
 import UIUtil from './util/UIUtil';
28
 import UIUtil from './util/UIUtil';
33
 
30
 
34
 const logger = Logger.getLogger(__filename);
31
 const logger = Logger.getLogger(__filename);
35
 
32
 
36
-const eventEmitter = new EventEmitter();
37
-
38
-UI.eventEmitter = eventEmitter;
39
-
40
 let etherpadManager;
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
  * Indicates if we're currently in full screen mode.
36
  * Indicates if we're currently in full screen mode.
54
  *
37
  *
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
     }
127
     }
144
     logger.log('Etherpad is enabled');
128
     logger.log('Etherpad is enabled');
145
 
129
 
146
-    etherpadManager = new EtherpadManager(eventEmitter);
130
+    etherpadManager = new EtherpadManager();
147
 
131
 
148
     const url = new URL(name, etherpadBaseUrl);
132
     const url = new URL(name, etherpadBaseUrl);
149
 
133
 
197
     }, NOTIFICATION_TIMEOUT_TYPE.SHORT));
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
  * Sets muted video state for participant
185
  * Sets muted video state for participant
211
  */
186
  */
219
 
194
 
220
 UI.updateLargeVideo = (id, forceUpdate) => VideoLayout.updateLargeVideo(id, forceUpdate);
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
 // Used by torture.
197
 // Used by torture.
250
 UI.showToolbar = timeout => APP.store.dispatch(showToolbox(timeout));
198
 UI.showToolbar = timeout => APP.store.dispatch(showToolbox(timeout));
251
 
199
 

+ 1
- 2
modules/UI/etherpad/Etherpad.js 查看文件

138
     /**
138
     /**
139
      *
139
      *
140
      */
140
      */
141
-    constructor(eventEmitter) {
142
-        this.eventEmitter = eventEmitter;
141
+    constructor() {
143
         this.etherpad = null;
142
         this.etherpad = null;
144
     }
143
     }
145
 
144
 

+ 1
- 3
react/features/base/audio-only/actions.ts 查看文件

1
-// @ts-expect-error
2
-import UIEvents from '../../../../service/UI/UIEvents';
3
 import { createAudioOnlyChangedEvent } from '../../analytics/AnalyticsEvents';
1
 import { createAudioOnlyChangedEvent } from '../../analytics/AnalyticsEvents';
4
 import { sendAnalytics } from '../../analytics/functions';
2
 import { sendAnalytics } from '../../analytics/functions';
5
 import { IStore } from '../../app/types';
3
 import { IStore } from '../../app/types';
33
             if (typeof APP !== 'undefined') {
31
             if (typeof APP !== 'undefined') {
34
                 // TODO This should be a temporary solution that lasts only until video
32
                 // TODO This should be a temporary solution that lasts only until video
35
                 // tracks and all ui is moved into react/redux on the web.
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 查看文件

1
-// @ts-expect-error
2
-import UIEvents from '../../../../service/UI/UIEvents';
3
 import { createStartMutedConfigurationEvent } from '../../analytics/AnalyticsEvents';
1
 import { createStartMutedConfigurationEvent } from '../../analytics/AnalyticsEvents';
4
 import { sendAnalytics } from '../../analytics/functions';
2
 import { sendAnalytics } from '../../analytics/functions';
5
 import { IReduxState, IStore } from '../../app/types';
3
 import { IReduxState, IStore } from '../../app/types';
1083
                                 dispatch(setAudioMuted(false, true));
1081
                                 dispatch(setAudioMuted(false, true));
1084
 
1082
 
1085
                                 // // FIXME: The old conference logic still relies on this event being emitted.
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
                                 dispatch(setVideoMuted(false, VIDEO_MUTISM_AUTHORITY.USER, true));
1094
                                 dispatch(setVideoMuted(false, VIDEO_MUTISM_AUTHORITY.USER, true));
1097
 
1095
 
1098
                                 // // FIXME: The old conference logic still relies on this event being emitted.
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 查看文件

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

+ 2
- 3
react/features/base/participants/middleware.ts 查看文件

2
 import { batch } from 'react-redux';
2
 import { batch } from 'react-redux';
3
 import { AnyAction } from 'redux';
3
 import { AnyAction } from 'redux';
4
 
4
 
5
-// @ts-expect-error
6
-import UIEvents from '../../../../service/UI/UIEvents';
7
 import { IStore } from '../../app/types';
5
 import { IStore } from '../../app/types';
8
 import { approveParticipant } from '../../av-moderation/actions';
6
 import { approveParticipant } from '../../av-moderation/actions';
9
 import { UPDATE_BREAKOUT_ROOMS } from '../../breakout-rooms/actionTypes';
7
 import { UPDATE_BREAKOUT_ROOMS } from '../../breakout-rooms/actionTypes';
20
 import { CALLING, INVITED } from '../../presence-status/constants';
18
 import { CALLING, INVITED } from '../../presence-status/constants';
21
 import { RAISE_HAND_SOUND_ID } from '../../reactions/constants';
19
 import { RAISE_HAND_SOUND_ID } from '../../reactions/constants';
22
 import { RECORDING_OFF_SOUND_ID, RECORDING_ON_SOUND_ID } from '../../recording/constants';
20
 import { RECORDING_OFF_SOUND_ID, RECORDING_ON_SOUND_ID } from '../../recording/constants';
21
+import { changeLocalDisplayName } from '../../settings/actions';
23
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app/actionTypes';
22
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app/actionTypes';
24
 import { CONFERENCE_WILL_JOIN } from '../conference/actionTypes';
23
 import { CONFERENCE_WILL_JOIN } from '../conference/actionTypes';
25
 import { forEachConference, getCurrentConference } from '../conference/functions';
24
 import { forEachConference, getCurrentConference } from '../conference/functions';
241
             const participant = getLocalParticipant(store.getState());
240
             const participant = getLocalParticipant(store.getState());
242
 
241
 
243
             if (participant && participant.id === action.id) {
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 查看文件

368
      */
368
      */
369
     _start() {
369
     _start() {
370
         APP.UI.start();
370
         APP.UI.start();
371
-
372
-        APP.UI.registerListeners();
373
         APP.UI.bindEvents();
371
         APP.UI.bindEvents();
374
 
372
 
375
         FULL_SCREEN_EVENTS.forEach(name =>
373
         FULL_SCREEN_EVENTS.forEach(name =>

+ 1
- 3
react/features/etherpad/middleware.ts 查看文件

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

+ 0
- 8
react/features/room-lock/middleware.ts 查看文件

1
 import { AnyAction } from 'redux';
1
 import { AnyAction } from 'redux';
2
 
2
 
3
-// @ts-expect-error
4
-import UIEvents from '../../../service/UI/UIEvents';
5
 import { IStore } from '../app/types';
3
 import { IStore } from '../app/types';
6
 import {
4
 import {
7
     CONFERENCE_FAILED,
5
     CONFERENCE_FAILED,
36
         return _conferenceJoined(store, next, action);
34
         return _conferenceJoined(store, next, action);
37
 
35
 
38
     case LOCK_STATE_CHANGED: {
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
         const previousLockedState = store.getState()['features/base/conference'].locked;
37
         const previousLockedState = store.getState()['features/base/conference'].locked;
46
 
38
 
47
         const result = next(action);
39
         const result = next(action);

+ 13
- 0
react/features/settings/actions.native.ts 查看文件

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 查看文件

12
 import { openDialog } from '../base/dialog/actions';
12
 import { openDialog } from '../base/dialog/actions';
13
 import i18next from '../base/i18n/i18next';
13
 import i18next from '../base/i18n/i18next';
14
 import { browser } from '../base/lib-jitsi-meet';
14
 import { browser } from '../base/lib-jitsi-meet';
15
+import { getNormalizedDisplayName } from '../base/participants/functions';
15
 import { updateSettings } from '../base/settings/actions';
16
 import { updateSettings } from '../base/settings/actions';
16
 import { getLocalVideoTrack } from '../base/tracks/functions.web';
17
 import { getLocalVideoTrack } from '../base/tracks/functions.web';
17
 import { appendURLHashParam } from '../base/util/uri';
18
 import { appendURLHashParam } from '../base/util/uri';
191
         const currentState = getProfileTabProps(getState());
192
         const currentState = getProfileTabProps(getState());
192
 
193
 
193
         if (newState.displayName !== currentState.displayName) {
194
         if (newState.displayName !== currentState.displayName) {
194
-            APP.conference.changeLocalDisplayName(newState.displayName);
195
+            dispatch(changeLocalDisplayName(newState.displayName));
195
         }
196
         }
196
 
197
 
197
         if (newState.email !== currentState.email) {
198
         if (newState.email !== currentState.email) {
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
  * Submits the settings from the "Sounds" tab of the settings dialog.
219
  * Submits the settings from the "Sounds" tab of the settings dialog.
205
  *
220
  *

+ 1
- 3
react/features/toolbox/actions.any.ts 查看文件

1
-// @ts-expect-error
2
-import UIEvents from '../../../service/UI/UIEvents';
3
 import { VIDEO_MUTE, createToolbarEvent } from '../analytics/AnalyticsEvents';
1
 import { VIDEO_MUTE, createToolbarEvent } from '../analytics/AnalyticsEvents';
4
 import { sendAnalytics } from '../analytics/functions';
2
 import { sendAnalytics } from '../analytics/functions';
5
 import { IStore } from '../app/types';
3
 import { IStore } from '../app/types';
103
         // FIXME: The old conference logic still relies on this event being
101
         // FIXME: The old conference logic still relies on this event being
104
         // emitted.
102
         // emitted.
105
         typeof APP === 'undefined'
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 查看文件

1
-// @ts-expect-error
2
-import UIEvents from '../../../service/UI/UIEvents';
3
 import {
1
 import {
4
     AUDIO_MUTE,
2
     AUDIO_MUTE,
5
     VIDEO_MUTE,
3
     VIDEO_MUTE,
55
             : setVideoMuted(enable, VIDEO_MUTISM_AUTHORITY.USER, /* ensureTrack */ true));
53
             : setVideoMuted(enable, VIDEO_MUTISM_AUTHORITY.USER, /* ensureTrack */ true));
56
 
54
 
57
         // FIXME: The old conference logic still relies on this event being emitted.
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 查看文件

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
-};

正在加载...
取消
保存