|
@@ -18,6 +18,7 @@ import {
|
18
|
18
|
import { MiddlewareRegistry } from '../redux';
|
19
|
19
|
import { isLocalVideoTrackDesktop } from '../tracks/functions';
|
20
|
20
|
|
|
21
|
+import { SET_LAST_N } from './actionTypes';
|
21
|
22
|
import { limitLastN } from './functions';
|
22
|
23
|
import logger from './logger';
|
23
|
24
|
|
|
@@ -40,6 +41,12 @@ MiddlewareRegistry.register(store => next => action => {
|
40
|
41
|
case SET_TILE_VIEW:
|
41
|
42
|
_updateLastN(store);
|
42
|
43
|
break;
|
|
44
|
+ case SET_LAST_N: {
|
|
45
|
+ const { lastN } = action;
|
|
46
|
+
|
|
47
|
+ _updateLastN(store, lastN);
|
|
48
|
+ break;
|
|
49
|
+ }
|
43
|
50
|
}
|
44
|
51
|
|
45
|
52
|
return result;
|
|
@@ -49,17 +56,18 @@ MiddlewareRegistry.register(store => next => action => {
|
49
|
56
|
* Updates the last N value in the conference based on the current state of the redux store.
|
50
|
57
|
*
|
51
|
58
|
* @param {Store} store - The redux store.
|
|
59
|
+ * @param {number} value - The last-n value to be set.
|
52
|
60
|
* @private
|
53
|
61
|
* @returns {void}
|
54
|
62
|
*/
|
55
|
|
-function _updateLastN({ getState }) {
|
|
63
|
+function _updateLastN({ getState }, value = null) {
|
56
|
64
|
const state = getState();
|
57
|
65
|
const { conference } = state['features/base/conference'];
|
58
|
66
|
const { enabled: audioOnly } = state['features/base/audio-only'];
|
59
|
67
|
const { appState } = state['features/background'] || {};
|
60
|
68
|
const { enabled: filmStripEnabled } = state['features/filmstrip'];
|
61
|
69
|
const config = state['features/base/config'];
|
62
|
|
- const { lastNLimits } = state['features/base/lastn'];
|
|
70
|
+ const { lastNLimits, lastN } = state['features/base/lastn'];
|
63
|
71
|
const participantCount = getParticipantCount(state);
|
64
|
72
|
|
65
|
73
|
if (!conference) {
|
|
@@ -68,17 +76,23 @@ function _updateLastN({ getState }) {
|
68
|
76
|
return;
|
69
|
77
|
}
|
70
|
78
|
|
71
|
|
- let lastN = typeof config.channelLastN === 'undefined' ? -1 : config.channelLastN;
|
|
79
|
+ // Select the lastN value based on the following preference order.
|
|
80
|
+ // 1. The value passed to the setLastN action that is dispatched.
|
|
81
|
+ // 2. The last-n value in redux.
|
|
82
|
+ // 3. The last-n value from 'startLastN' if it is specified in config.js
|
|
83
|
+ // 4. The last-n value from 'channelLastN' if specified in config.js.
|
|
84
|
+ // 5. -1 as the default value.
|
|
85
|
+ let lastNSelected = value || lastN || (config.startLastN ?? (config.channelLastN ?? -1));
|
72
|
86
|
|
73
|
|
- // Apply last N limit based on the # of participants and channelLastN settings.
|
|
87
|
+ // Apply last N limit based on the # of participants and config settings.
|
74
|
88
|
const limitedLastN = limitLastN(participantCount, lastNLimits);
|
75
|
89
|
|
76
|
90
|
if (limitedLastN !== undefined) {
|
77
|
|
- lastN = lastN === -1 ? limitedLastN : Math.min(limitedLastN, lastN);
|
|
91
|
+ lastNSelected = lastNSelected === -1 ? limitedLastN : Math.min(limitedLastN, lastNSelected);
|
78
|
92
|
}
|
79
|
93
|
|
80
|
94
|
if (typeof appState !== 'undefined' && appState !== 'active') {
|
81
|
|
- lastN = isLocalVideoTrackDesktop(state) ? 1 : 0;
|
|
95
|
+ lastNSelected = isLocalVideoTrackDesktop(state) ? 1 : 0;
|
82
|
96
|
} else if (audioOnly) {
|
83
|
97
|
const { remoteScreenShares, tileViewEnabled } = state['features/video-layout'];
|
84
|
98
|
const largeVideoParticipantId = state['features/large-video'].participantId;
|
|
@@ -89,22 +103,22 @@ function _updateLastN({ getState }) {
|
89
|
103
|
// view since we make an exception only for screenshare when in audio-only mode. If the user unpins
|
90
|
104
|
// the screenshare, lastN will be set to 0 here. It will be set to 1 if screenshare has been auto pinned.
|
91
|
105
|
if (!tileViewEnabled && largeVideoParticipant && !largeVideoParticipant.local) {
|
92
|
|
- lastN = (remoteScreenShares || []).includes(largeVideoParticipantId) ? 1 : 0;
|
|
106
|
+ lastNSelected = (remoteScreenShares || []).includes(largeVideoParticipantId) ? 1 : 0;
|
93
|
107
|
} else {
|
94
|
|
- lastN = 0;
|
|
108
|
+ lastNSelected = 0;
|
95
|
109
|
}
|
96
|
110
|
} else if (!filmStripEnabled) {
|
97
|
|
- lastN = 1;
|
|
111
|
+ lastNSelected = 1;
|
98
|
112
|
}
|
99
|
113
|
|
100
|
|
- if (conference.getLastN() === lastN) {
|
|
114
|
+ if (conference.getLastN() === lastNSelected) {
|
101
|
115
|
return;
|
102
|
116
|
}
|
103
|
117
|
|
104
|
|
- logger.info(`Setting last N to: ${lastN}`);
|
|
118
|
+ logger.info(`Setting last N to: ${lastNSelected}`);
|
105
|
119
|
|
106
|
120
|
try {
|
107
|
|
- conference.setLastN(lastN);
|
|
121
|
+ conference.setLastN(lastNSelected);
|
108
|
122
|
} catch (err) {
|
109
|
123
|
logger.error(`Failed to set lastN: ${err}`);
|
110
|
124
|
}
|