mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2025-12-30 11:22:31 +00:00
feat(raised-hand) Change raisedHand to a timestamp instead of boole… (#10167)
- this was needed for sorting the raised hand participants in participants pane in the order they raised their hand also for participants joining late
This commit is contained in:
@@ -94,7 +94,7 @@ MiddlewareRegistry.register(store => next => action => {
|
||||
const participant = getLocalParticipant(state);
|
||||
const isLocal = participant && participant.id === id;
|
||||
|
||||
if (isLocal && participant.raisedHand === undefined) {
|
||||
if (isLocal && participant.raisedHandTimestamp === undefined) {
|
||||
// if local was undefined, let's leave it like that
|
||||
// avoids sending unnecessary presence updates
|
||||
break;
|
||||
@@ -105,7 +105,7 @@ MiddlewareRegistry.register(store => next => action => {
|
||||
conference,
|
||||
id,
|
||||
local: isLocal,
|
||||
raisedHand: false
|
||||
raisedHandTimestamp: 0
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -127,14 +127,9 @@ MiddlewareRegistry.register(store => next => action => {
|
||||
}
|
||||
|
||||
case LOCAL_PARTICIPANT_RAISE_HAND: {
|
||||
const { enabled } = action;
|
||||
const { raisedHandTimestamp } = action;
|
||||
const localId = getLocalParticipant(store.getState())?.id;
|
||||
|
||||
store.dispatch(raiseHandUpdateQueue({
|
||||
id: localId,
|
||||
raisedHand: enabled
|
||||
}));
|
||||
|
||||
store.dispatch(participantUpdated({
|
||||
// XXX Only the local participant is allowed to update without
|
||||
// stating the JitsiConference instance (i.e. participant property
|
||||
@@ -144,11 +139,16 @@ MiddlewareRegistry.register(store => next => action => {
|
||||
|
||||
id: localId,
|
||||
local: true,
|
||||
raisedHand: enabled
|
||||
raisedHandTimestamp
|
||||
}));
|
||||
|
||||
store.dispatch(raiseHandUpdateQueue({
|
||||
id: localId,
|
||||
raisedHandTimestamp
|
||||
}));
|
||||
|
||||
if (typeof APP !== 'undefined') {
|
||||
APP.API.notifyRaiseHandUpdated(localId, enabled);
|
||||
APP.API.notifyRaiseHandUpdated(localId, raisedHandTimestamp);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -177,16 +177,22 @@ MiddlewareRegistry.register(store => next => action => {
|
||||
|
||||
case RAISE_HAND_UPDATED: {
|
||||
const { participant } = action;
|
||||
const queue = getRaiseHandsQueue(store.getState());
|
||||
let queue = getRaiseHandsQueue(store.getState());
|
||||
|
||||
if (participant.raisedHand) {
|
||||
queue.push(participant.id);
|
||||
action.queue = queue;
|
||||
if (participant.raisedHandTimestamp) {
|
||||
queue.push({
|
||||
id: participant.id,
|
||||
raisedHandTimestamp: participant.raisedHandTimestamp
|
||||
});
|
||||
|
||||
// sort the queue before adding to store.
|
||||
queue = queue.sort(({ raisedHandTimestamp: a }, { raisedHandTimestamp: b }) => a - b);
|
||||
} else {
|
||||
const filteredQueue = queue.filter(id => id !== participant.id);
|
||||
|
||||
action.queue = filteredQueue;
|
||||
// no need to sort on remove value.
|
||||
queue = queue.filter(({ id }) => id !== participant.id);
|
||||
}
|
||||
|
||||
action.queue = queue;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -287,7 +293,8 @@ StateListenerRegistry.register(
|
||||
id: participant.getId(),
|
||||
features: { 'screen-sharing': true }
|
||||
})),
|
||||
'raisedHand': (participant, value) => _raiseHandUpdated(store, conference, participant.getId(), value),
|
||||
'raisedHand': (participant, value) =>
|
||||
_raiseHandUpdated(store, conference, participant.getId(), value),
|
||||
'remoteControlSessionStatus': (participant, value) =>
|
||||
store.dispatch(participantUpdated({
|
||||
conference,
|
||||
@@ -320,7 +327,7 @@ StateListenerRegistry.register(
|
||||
|
||||
// We left the conference, the local participant must be updated.
|
||||
_e2eeUpdated(store, conference, localParticipantId, false);
|
||||
_raiseHandUpdated(store, conference, localParticipantId, false);
|
||||
_raiseHandUpdated(store, conference, localParticipantId, 0);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -451,18 +458,19 @@ function _maybePlaySounds({ getState, dispatch }, action) {
|
||||
*/
|
||||
function _participantJoinedOrUpdated(store, next, action) {
|
||||
const { dispatch, getState } = store;
|
||||
const { participant: { avatarURL, email, id, local, name, raisedHand } } = action;
|
||||
const { participant: { avatarURL, email, id, local, name, raisedHandTimestamp } } = action;
|
||||
|
||||
// Send an external update of the local participant's raised hand state
|
||||
// if a new raised hand state is defined in the action.
|
||||
if (typeof raisedHand !== 'undefined') {
|
||||
if (typeof raisedHandTimestamp !== 'undefined') {
|
||||
|
||||
if (local) {
|
||||
const { conference } = getState()['features/base/conference'];
|
||||
const rHand = parseInt(raisedHandTimestamp, 10);
|
||||
|
||||
// Send raisedHand signalling only if there is a change
|
||||
if (conference && raisedHand !== getLocalParticipant(getState()).raisedHand) {
|
||||
conference.setLocalParticipantProperty('raisedHand', raisedHand);
|
||||
if (conference && rHand !== getLocalParticipant(getState()).raisedHandTimestamp) {
|
||||
conference.setLocalParticipantProperty('raisedHand', rHand);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -508,22 +516,34 @@ function _participantJoinedOrUpdated(store, next, action) {
|
||||
* @returns {void}
|
||||
*/
|
||||
function _raiseHandUpdated({ dispatch, getState }, conference, participantId, newValue) {
|
||||
const raisedHand = newValue === 'true';
|
||||
let raisedHandTimestamp;
|
||||
|
||||
switch (newValue) {
|
||||
case undefined:
|
||||
case 'false':
|
||||
raisedHandTimestamp = 0;
|
||||
break;
|
||||
case 'true':
|
||||
raisedHandTimestamp = Date.now();
|
||||
break;
|
||||
default:
|
||||
raisedHandTimestamp = parseInt(newValue, 10);
|
||||
}
|
||||
const state = getState();
|
||||
|
||||
dispatch(participantUpdated({
|
||||
conference,
|
||||
id: participantId,
|
||||
raisedHand
|
||||
raisedHandTimestamp
|
||||
}));
|
||||
|
||||
dispatch(raiseHandUpdateQueue({
|
||||
id: participantId,
|
||||
raisedHand
|
||||
raisedHandTimestamp
|
||||
}));
|
||||
|
||||
if (typeof APP !== 'undefined') {
|
||||
APP.API.notifyRaiseHandUpdated(participantId, raisedHand);
|
||||
APP.API.notifyRaiseHandUpdated(participantId, raisedHandTimestamp);
|
||||
}
|
||||
|
||||
const isModerator = isLocalParticipantModerator(state);
|
||||
@@ -540,7 +560,7 @@ function _raiseHandUpdated({ dispatch, getState }, conference, participantId, ne
|
||||
customActionHandler: () => dispatch(approveParticipant(participantId))
|
||||
} : {};
|
||||
|
||||
if (raisedHand) {
|
||||
if (raisedHandTimestamp) {
|
||||
dispatch(showNotification({
|
||||
titleKey: 'notify.somebody',
|
||||
title: getParticipantDisplayName(state, participantId),
|
||||
|
||||
Reference in New Issue
Block a user