2018-02-12 17:42:38 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-08-18 22:34:01 +00:00
|
|
|
import { PARTICIPANT_LEFT } from '../base/participants';
|
2017-05-23 18:58:07 +00:00
|
|
|
import { ReducerRegistry } from '../base/redux';
|
2018-02-05 21:52:41 +00:00
|
|
|
|
2018-02-06 09:40:16 +00:00
|
|
|
import {
|
2022-03-29 08:45:09 +00:00
|
|
|
REMOVE_STAGE_PARTICIPANT,
|
|
|
|
SET_STAGE_PARTICIPANTS,
|
2018-02-06 09:40:16 +00:00
|
|
|
SET_FILMSTRIP_ENABLED,
|
2020-01-24 16:28:47 +00:00
|
|
|
SET_FILMSTRIP_VISIBLE,
|
2022-02-24 12:20:37 +00:00
|
|
|
SET_FILMSTRIP_WIDTH,
|
2020-01-24 16:28:47 +00:00
|
|
|
SET_HORIZONTAL_VIEW_DIMENSIONS,
|
2021-08-18 22:34:01 +00:00
|
|
|
SET_REMOTE_PARTICIPANTS,
|
2022-03-29 08:45:09 +00:00
|
|
|
SET_STAGE_FILMSTRIP_DIMENSIONS,
|
2021-03-26 20:23:05 +00:00
|
|
|
SET_TILE_VIEW_DIMENSIONS,
|
2022-02-24 12:20:37 +00:00
|
|
|
SET_USER_FILMSTRIP_WIDTH,
|
2022-03-14 11:11:22 +00:00
|
|
|
SET_USER_IS_RESIZING,
|
2021-03-26 20:23:05 +00:00
|
|
|
SET_VERTICAL_VIEW_DIMENSIONS,
|
2021-05-19 23:23:40 +00:00
|
|
|
SET_VISIBLE_REMOTE_PARTICIPANTS,
|
2022-04-07 08:31:53 +00:00
|
|
|
SET_VOLUME,
|
2022-04-12 13:19:10 +00:00
|
|
|
SET_MAX_STAGE_PARTICIPANTS,
|
|
|
|
CLEAR_STAGE_PARTICIPANTS
|
2018-02-06 09:40:16 +00:00
|
|
|
} from './actionTypes';
|
2017-05-23 18:58:07 +00:00
|
|
|
|
|
|
|
const DEFAULT_STATE = {
|
2022-03-29 08:45:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The list of participants to be displayed on the stage filmstrip.
|
|
|
|
*/
|
|
|
|
activeParticipants: [],
|
|
|
|
|
2018-02-12 17:42:38 +00:00
|
|
|
/**
|
|
|
|
* The indicator which determines whether the {@link Filmstrip} is enabled.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2018-02-06 09:40:16 +00:00
|
|
|
enabled: true,
|
2018-02-12 17:42:38 +00:00
|
|
|
|
2020-01-24 16:28:47 +00:00
|
|
|
/**
|
|
|
|
* The horizontal view dimensions.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
horizontalViewDimensions: {},
|
|
|
|
|
2022-03-14 11:11:22 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the user is actively resizing the filmstrip.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
isResizing: false,
|
|
|
|
|
2022-04-07 08:31:53 +00:00
|
|
|
/**
|
|
|
|
* The current max number of participants to be displayed on the stage filmstrip.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {Number}
|
|
|
|
*/
|
|
|
|
maxStageParticipants: 4,
|
|
|
|
|
2021-03-26 20:23:05 +00:00
|
|
|
/**
|
2021-06-30 07:30:38 +00:00
|
|
|
* The custom audio volume levels per participant.
|
2021-03-26 20:23:05 +00:00
|
|
|
*
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
participantsVolume: {},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The ordered IDs of the remote participants displayed in the filmstrip.
|
|
|
|
*
|
2021-08-18 22:34:01 +00:00
|
|
|
* @public
|
|
|
|
* @type {Array<string>}
|
2021-03-26 20:23:05 +00:00
|
|
|
*/
|
|
|
|
remoteParticipants: [],
|
|
|
|
|
2022-03-29 08:45:09 +00:00
|
|
|
/**
|
|
|
|
* The stage filmstrip view dimensions.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
stageFilmstripDimensions: {},
|
|
|
|
|
2020-01-24 16:28:47 +00:00
|
|
|
/**
|
|
|
|
* The tile view dimensions.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
tileViewDimensions: {},
|
|
|
|
|
2021-03-26 20:23:05 +00:00
|
|
|
/**
|
|
|
|
* The vertical view dimensions.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
verticalViewDimensions: {},
|
|
|
|
|
2018-02-12 17:42:38 +00:00
|
|
|
/**
|
|
|
|
* The indicator which determines whether the {@link Filmstrip} is visible.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2021-05-19 23:23:40 +00:00
|
|
|
visible: true,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The end index in the remote participants array that is visible in the filmstrip.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
visibleParticipantsEndIndex: 0,
|
|
|
|
|
|
|
|
/**
|
2021-08-18 22:34:01 +00:00
|
|
|
* The start index in the remote participants array that is visible in the filmstrip.
|
2021-05-19 23:23:40 +00:00
|
|
|
*
|
|
|
|
* @public
|
2021-08-18 22:34:01 +00:00
|
|
|
* @type {number}
|
2021-05-19 23:23:40 +00:00
|
|
|
*/
|
2021-08-18 22:34:01 +00:00
|
|
|
visibleParticipantsStartIndex: 0,
|
2021-05-19 23:23:40 +00:00
|
|
|
|
|
|
|
/**
|
2021-08-18 22:34:01 +00:00
|
|
|
* The visible remote participants in the filmstrip.
|
2021-05-19 23:23:40 +00:00
|
|
|
*
|
|
|
|
* @public
|
2021-08-18 22:34:01 +00:00
|
|
|
* @type {Set<string>}
|
2021-05-19 23:23:40 +00:00
|
|
|
*/
|
2022-02-24 12:20:37 +00:00
|
|
|
visibleRemoteParticipants: new Set(),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The width of the resizable filmstrip.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
width: {
|
|
|
|
/**
|
|
|
|
* Current width. Affected by: user filmstrip resize,
|
|
|
|
* window resize, panels open/ close.
|
|
|
|
*/
|
|
|
|
current: null,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Width set by user resize. Used as the preferred width.
|
|
|
|
*/
|
|
|
|
userSet: null
|
|
|
|
}
|
2017-05-23 18:58:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ReducerRegistry.register(
|
|
|
|
'features/filmstrip',
|
|
|
|
(state = DEFAULT_STATE, action) => {
|
|
|
|
switch (action.type) {
|
2018-02-06 09:40:16 +00:00
|
|
|
case SET_FILMSTRIP_ENABLED:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
enabled: action.enabled
|
|
|
|
};
|
|
|
|
|
2018-02-05 21:52:41 +00:00
|
|
|
case SET_FILMSTRIP_VISIBLE:
|
2017-05-23 18:58:07 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
visible: action.visible
|
|
|
|
};
|
2020-01-24 16:28:47 +00:00
|
|
|
|
|
|
|
case SET_HORIZONTAL_VIEW_DIMENSIONS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
horizontalViewDimensions: action.dimensions
|
|
|
|
};
|
2021-08-18 22:34:01 +00:00
|
|
|
case SET_REMOTE_PARTICIPANTS: {
|
|
|
|
state.remoteParticipants = action.participants;
|
2021-08-20 23:32:38 +00:00
|
|
|
const { visibleParticipantsStartIndex: startIndex, visibleParticipantsEndIndex: endIndex } = state;
|
2021-08-23 23:02:41 +00:00
|
|
|
|
2021-08-20 23:32:38 +00:00
|
|
|
state.visibleRemoteParticipants = new Set(state.remoteParticipants.slice(startIndex, endIndex + 1));
|
2021-08-18 22:34:01 +00:00
|
|
|
|
|
|
|
return { ...state };
|
|
|
|
}
|
2020-01-24 16:28:47 +00:00
|
|
|
case SET_TILE_VIEW_DIMENSIONS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
tileViewDimensions: action.dimensions
|
|
|
|
};
|
2021-03-26 20:23:05 +00:00
|
|
|
case SET_VERTICAL_VIEW_DIMENSIONS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
verticalViewDimensions: action.dimensions
|
|
|
|
};
|
|
|
|
case SET_VOLUME:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
participantsVolume: {
|
|
|
|
...state.participantsVolume,
|
|
|
|
|
|
|
|
// NOTE: This would fit better in the features/base/participants. But currently we store
|
|
|
|
// the participants as an array which will make it expensive to search for the volume for
|
|
|
|
// every participant separately.
|
|
|
|
[action.participantId]: action.volume
|
|
|
|
}
|
|
|
|
};
|
2021-08-18 22:34:01 +00:00
|
|
|
case SET_VISIBLE_REMOTE_PARTICIPANTS: {
|
2021-05-19 23:23:40 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
visibleParticipantsStartIndex: action.startIndex,
|
|
|
|
visibleParticipantsEndIndex: action.endIndex,
|
2021-08-19 21:56:45 +00:00
|
|
|
visibleRemoteParticipants:
|
|
|
|
new Set(state.remoteParticipants.slice(action.startIndex, action.endIndex + 1))
|
2021-05-19 23:23:40 +00:00
|
|
|
};
|
2021-03-26 20:23:05 +00:00
|
|
|
}
|
|
|
|
case PARTICIPANT_LEFT: {
|
|
|
|
const { id, local } = action.participant;
|
|
|
|
|
|
|
|
if (local) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
delete state.participantsVolume[id];
|
|
|
|
|
2021-08-20 23:32:38 +00:00
|
|
|
return {
|
|
|
|
...state
|
|
|
|
};
|
2021-03-26 20:23:05 +00:00
|
|
|
}
|
2022-02-24 12:20:37 +00:00
|
|
|
case SET_FILMSTRIP_WIDTH: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
width: {
|
|
|
|
...state.width,
|
|
|
|
current: action.width
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
case SET_USER_FILMSTRIP_WIDTH: {
|
|
|
|
const { width } = action;
|
|
|
|
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
width: {
|
|
|
|
current: width,
|
|
|
|
userSet: width
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2022-03-14 11:11:22 +00:00
|
|
|
case SET_USER_IS_RESIZING: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isResizing: action.resizing
|
|
|
|
};
|
|
|
|
}
|
2022-03-29 08:45:09 +00:00
|
|
|
case SET_STAGE_FILMSTRIP_DIMENSIONS: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
stageFilmstripDimensions: action.dimensions
|
|
|
|
};
|
|
|
|
}
|
|
|
|
case SET_STAGE_PARTICIPANTS: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeParticipants: action.queue
|
|
|
|
};
|
|
|
|
}
|
|
|
|
case REMOVE_STAGE_PARTICIPANT: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeParticipants: state.activeParticipants.filter(p => p.participantId !== action.participantId)
|
|
|
|
};
|
|
|
|
}
|
2022-04-07 08:31:53 +00:00
|
|
|
case SET_MAX_STAGE_PARTICIPANTS: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
maxStageParticipants: action.maxParticipants
|
|
|
|
};
|
|
|
|
}
|
2022-04-12 13:19:10 +00:00
|
|
|
case CLEAR_STAGE_PARTICIPANTS: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeParticipants: []
|
|
|
|
};
|
|
|
|
}
|
2017-05-23 18:58:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
});
|