From 1c4283eecabd481cb2d2795840196fbfe36e7534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=8F=D0=BD=20=D0=9C=D0=B8=D0=BD=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Wed, 22 Dec 2021 10:55:08 -0600 Subject: [PATCH] feat: Edits messages display name on breakout info received. Fixes #10671. --- react/features/breakout-rooms/middleware.js | 39 ++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/react/features/breakout-rooms/middleware.js b/react/features/breakout-rooms/middleware.js index d3f3d3777..88b611a89 100644 --- a/react/features/breakout-rooms/middleware.js +++ b/react/features/breakout-rooms/middleware.js @@ -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; +});