feat: Edits messages display name on breakout info received. Fixes #10671.
This commit is contained in:
parent
c64d1a97c1
commit
1c4283eeca
|
@ -1,10 +1,13 @@
|
|||
// @flow
|
||||
|
||||
import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
|
||||
import { StateListenerRegistry } from '../base/redux';
|
||||
import { getParticipantById } from '../base/participants';
|
||||
import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
|
||||
import { editMessage, MESSAGE_TYPE_REMOTE } from '../chat';
|
||||
|
||||
import { UPDATE_BREAKOUT_ROOMS } from './actionTypes';
|
||||
import { moveToRoom } from './actions';
|
||||
import { getBreakoutRooms } from './functions';
|
||||
import logger from './logger';
|
||||
|
||||
/**
|
||||
|
@ -30,3 +33,37 @@ StateListenerRegistry.register(
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
|
||||
const { type } = action;
|
||||
const result = next(action);
|
||||
|
||||
switch (type) {
|
||||
case UPDATE_BREAKOUT_ROOMS: {
|
||||
const { messages } = getState()['features/chat'];
|
||||
|
||||
// edit the chat history to match names for participants in breakout rooms
|
||||
messages && messages.forEach(m => {
|
||||
if (m.messageType === MESSAGE_TYPE_REMOTE && !getParticipantById(getState(), m.id)) {
|
||||
const rooms = getBreakoutRooms(getState);
|
||||
|
||||
for (const room of Object.values(rooms)) {
|
||||
// $FlowExpectedError
|
||||
const participants = room.participants || {};
|
||||
const matchedJid = Object.keys(participants).find(jid => jid.endsWith(m.id));
|
||||
|
||||
if (matchedJid) {
|
||||
m.displayName = participants[matchedJid].displayName;
|
||||
|
||||
dispatch(editMessage(m));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue