Procházet zdrojové kódy

fix(breakout-rooms) close room before removing it (#10956)

factor2
Mihaela Dumitru před 3 roky
rodič
revize
79877e56f0
Žádný účet není propojen s e-mailovou adresou tvůrce revize

+ 13
- 1
react/features/breakout-rooms/actions.js Zobrazit soubor

@@ -33,7 +33,8 @@ import { _RESET_BREAKOUT_ROOMS, _UPDATE_ROOM_COUNTER } from './actionTypes';
33 33
 import { FEATURE_KEY } from './constants';
34 34
 import {
35 35
     getBreakoutRooms,
36
-    getMainRoom
36
+    getMainRoom,
37
+    getRoomByJid
37 38
 } from './functions';
38 39
 import logger from './logger';
39 40
 
@@ -97,6 +98,17 @@ export function closeBreakoutRoom(roomId: string) {
97 98
 export function removeBreakoutRoom(breakoutRoomJid: string) {
98 99
     return (dispatch: Dispatch<any>, getState: Function) => {
99 100
         sendAnalytics(createBreakoutRoomsEvent('remove'));
101
+        const room = getRoomByJid(getState, breakoutRoomJid);
102
+
103
+        if (!room) {
104
+            logger.error('The room to remove was not found.');
105
+
106
+            return;
107
+        }
108
+
109
+        if (Object.keys(room.participants).length > 0) {
110
+            dispatch(closeBreakoutRoom(room.id));
111
+        }
100 112
 
101 113
         // $FlowExpectedError
102 114
         getCurrentConference(getState)?.getBreakoutRooms()

+ 14
- 0
react/features/breakout-rooms/functions.js Zobrazit soubor

@@ -29,6 +29,20 @@ export const getMainRoom = (stateful: Function | Object) => {
29 29
     return _.find(rooms, (room: Object) => room.isMainRoom);
30 30
 };
31 31
 
32
+/**
33
+ * Returns the room by Jid.
34
+ *
35
+ * @param {Function|Object} stateful - The redux store, the redux
36
+ * {@code getState} function, or the redux state itself.
37
+ * @param {string} roomJid - The jid of the room.
38
+ * @returns {Object|undefined} The main room object, or undefined.
39
+ */
40
+export const getRoomByJid = (stateful: Function | Object, roomJid: string): Object => {
41
+    const rooms = getBreakoutRooms(stateful);
42
+
43
+    return _.find(rooms, (room: Object) => room.jid === roomJid);
44
+};
45
+
32 46
 /**
33 47
  * Returns the id of the current room.
34 48
  *

Načítá se…
Zrušit
Uložit