|
@@ -2,15 +2,12 @@
|
2
|
2
|
|
3
|
3
|
import debounce from 'lodash/debounce';
|
4
|
4
|
|
5
|
|
-import { pinParticipant, getPinnedParticipant } from '../base/participants';
|
6
|
5
|
import { StateListenerRegistry, equals } from '../base/redux';
|
7
|
6
|
import { isFollowMeActive } from '../follow-me';
|
8
|
|
-import { selectParticipant } from '../large-video/actions';
|
|
7
|
+import { selectParticipant } from '../large-video/actions.any';
|
9
|
8
|
|
10
|
9
|
import { setRemoteParticipantsWithScreenShare } from './actions';
|
11
|
|
-
|
12
|
|
-declare var APP: Object;
|
13
|
|
-declare var interfaceConfig: Object;
|
|
10
|
+import { getAutoPinSetting, updateAutoPinnedParticipant } from './functions';
|
14
|
11
|
|
15
|
12
|
/**
|
16
|
13
|
* StateListenerRegistry provides a reliable way of detecting changes to
|
|
@@ -33,14 +30,14 @@ StateListenerRegistry.register(
|
33
|
30
|
StateListenerRegistry.register(
|
34
|
31
|
/* selector */ state => state['features/base/tracks'],
|
35
|
32
|
/* listener */ debounce((tracks, store) => {
|
36
|
|
- if (!_getAutoPinSetting() || isFollowMeActive(store)) {
|
|
33
|
+ if (!getAutoPinSetting() || isFollowMeActive(store)) {
|
37
|
34
|
return;
|
38
|
35
|
}
|
39
|
36
|
|
40
|
37
|
const oldScreenSharesOrder = store.getState()['features/video-layout'].remoteScreenShares || [];
|
41
|
38
|
const knownSharingParticipantIds = tracks.reduce((acc, track) => {
|
42
|
39
|
if (track.mediaType === 'video' && track.videoType === 'desktop') {
|
43
|
|
- const skipTrack = _getAutoPinSetting() === 'remote-only' && track.local;
|
|
40
|
+ const skipTrack = getAutoPinSetting() === 'remote-only' && track.local;
|
44
|
41
|
|
45
|
42
|
if (!skipTrack) {
|
46
|
43
|
acc.push(track.participantId);
|
|
@@ -68,60 +65,6 @@ StateListenerRegistry.register(
|
68
|
65
|
store.dispatch(
|
69
|
66
|
setRemoteParticipantsWithScreenShare(newScreenSharesOrder));
|
70
|
67
|
|
71
|
|
- _updateAutoPinnedParticipant(oldScreenSharesOrder, store);
|
|
68
|
+ updateAutoPinnedParticipant(oldScreenSharesOrder, store);
|
72
|
69
|
}
|
73
|
70
|
}, 100));
|
74
|
|
-
|
75
|
|
-/**
|
76
|
|
- * A selector for retrieving the current automatic pinning setting.
|
77
|
|
- *
|
78
|
|
- * @private
|
79
|
|
- * @returns {string|undefined} The string "remote-only" is returned if only
|
80
|
|
- * remote screensharing should be automatically pinned, any other truthy value
|
81
|
|
- * means automatically pin all screenshares. Falsy means do not automatically
|
82
|
|
- * pin any screenshares.
|
83
|
|
- */
|
84
|
|
-function _getAutoPinSetting() {
|
85
|
|
- return typeof interfaceConfig === 'object'
|
86
|
|
- ? interfaceConfig.AUTO_PIN_LATEST_SCREEN_SHARE
|
87
|
|
- : 'remote-only';
|
88
|
|
-}
|
89
|
|
-
|
90
|
|
-/**
|
91
|
|
- * Private helper to automatically pin the latest screen share stream or unpin
|
92
|
|
- * if there are no more screen share streams.
|
93
|
|
- *
|
94
|
|
- * @param {Array<string>} screenShares - Array containing the list of all the screensharing endpoints
|
95
|
|
- * before the update was triggered (including the ones that have been removed from redux because of the update).
|
96
|
|
- * @param {Store} store - The redux store.
|
97
|
|
- * @returns {void}
|
98
|
|
- */
|
99
|
|
-function _updateAutoPinnedParticipant(screenShares, { dispatch, getState }) {
|
100
|
|
- const state = getState();
|
101
|
|
- const remoteScreenShares = state['features/video-layout'].remoteScreenShares;
|
102
|
|
- const pinned = getPinnedParticipant(getState);
|
103
|
|
-
|
104
|
|
- // if the pinned participant is shared video or some other fake participant we want to skip auto-pinning
|
105
|
|
- if (pinned?.isFakeParticipant) {
|
106
|
|
- return;
|
107
|
|
- }
|
108
|
|
-
|
109
|
|
- // Unpin the screenshare when the screensharing participant leaves. Switch to tile view if no other
|
110
|
|
- // participant was pinned before screenshare was auto-pinned, pin the previously pinned participant otherwise.
|
111
|
|
- if (!remoteScreenShares?.length) {
|
112
|
|
- let participantId = null;
|
113
|
|
-
|
114
|
|
- if (pinned && !screenShares.find(share => share === pinned.id)) {
|
115
|
|
- participantId = pinned.id;
|
116
|
|
- }
|
117
|
|
- dispatch(pinParticipant(participantId));
|
118
|
|
-
|
119
|
|
- return;
|
120
|
|
- }
|
121
|
|
-
|
122
|
|
- const latestScreenshareParticipantId = remoteScreenShares[remoteScreenShares.length - 1];
|
123
|
|
-
|
124
|
|
- if (latestScreenshareParticipantId) {
|
125
|
|
- dispatch(pinParticipant(latestScreenshareParticipantId));
|
126
|
|
- }
|
127
|
|
-}
|