Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kicked event #14954

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/API/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -1814,9 +1814,9 @@ class API {
* Notify external application of a participant, remote or local, being
* removed from the conference by another participant.
*
* @param {string} kicked - The ID of the participant removed from the
* @param {Object} kicked - The participant removed from the
* conference.
* @param {string} kicker - The ID of the participant that removed the
* @param {Object} kicker - The participant that removed the
* other participant.
* @returns {void}
*/
Expand Down
14 changes: 9 additions & 5 deletions react/features/base/participants/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,23 +544,27 @@ export function createVirtualScreenshareParticipant(sourceName: string, local: b
*/
export function participantKicked(kicker: any, kicked: any) {
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const state = getState();
const localParticipant = getLocalParticipant(state);
const kickedId = kicked.getId();
const kickerId = kicker.getId();

dispatch({
type: PARTICIPANT_KICKED,
kicked: kicked.getId(),
kicker: kicker?.getId()
kicked: kickedId,
kicker: kickerId
});

if (kicked.isReplaced?.()) {
if (kicked.isReplaced?.() || kickerId === localParticipant?.id) {
return;
}

dispatch(showNotification({
titleArguments: {
kicked:
getParticipantDisplayName(getState, kicked.getId()),
getParticipantDisplayName(state, kickedId),
kicker:
getParticipantDisplayName(getState, kicker.getId())
getParticipantDisplayName(state, kickerId)
},
titleKey: 'notify.kickParticipant'
}, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
Expand Down
45 changes: 37 additions & 8 deletions react/features/external-api/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
import {
getDominantSpeakerParticipant,
getLocalParticipant,
getParticipantById
getParticipantById,
getParticipantDisplayName
} from '../base/participants/functions';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { getBaseUrl } from '../base/util/helpers';
Expand Down Expand Up @@ -133,15 +134,29 @@ MiddlewareRegistry.register(store => next => action => {
APP.API.notifyDataChannelOpened();
break;

case KICKED_OUT:
case KICKED_OUT: {
const state = store.getState();
const localParticipant = getLocalParticipant(state);

if (!localParticipant) {
break;
}

const pId = action.participant.getId();

APP.API.notifyKickedOut(
{
id: getLocalParticipant(store.getState())?.id,
id: localParticipant.id,
name: getParticipantDisplayName(state, localParticipant.id),
local: true
},
{ id: action.participant ? action.participant.getId() : undefined }
{
id: pId,
name: getParticipantDisplayName(state, pId)
}
);
break;
}

case NOTIFY_CAMERA_ERROR:
if (action.error) {
Expand All @@ -156,14 +171,28 @@ MiddlewareRegistry.register(store => next => action => {
}
break;

case PARTICIPANT_KICKED:
case PARTICIPANT_KICKED: {
const state = store.getState();
const kickedParticipant = getParticipantById(state, action.kicked);
const kickerParticipant = getParticipantById(state, action.kicker);

if (!kickerParticipant || !kickedParticipant) {
break;
}

APP.API.notifyKickedOut(
{
id: action.kicked,
local: false
id: kickedParticipant.id,
local: kickedParticipant.local,
name: getParticipantDisplayName(state, kickedParticipant.id)
},
{ id: action.kicker });
{
id: kickerParticipant.id,
local: kickerParticipant.local,
name: getParticipantDisplayName(state, kickerParticipant.id)
});
break;
}

case PARTICIPANT_LEFT: {
const { participant } = action;
Expand Down