Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(breakout-rooms) add notification when joining rooms

Saúl Ibarra Corretgéda0cb2b83794
diff --git a/lang/main.json b/lang/main.json
index 2964fe8ae6..927115ed1b 100644
--- a/lang/main.json
+++ b/lang/main.json
@@ -54,6 +54,11 @@
"more": "More",
"remove": "Remove",
"sendToBreakoutRoom": "Send participant to:"
+ },
+ "notifications": {
+ "joinedTitle": "Breakout Rooms",
+ "joined": "Joining the \"{{name}}\" breakout room",
+ "joinedMainRoom": "Joining the main room"
}
},
"calendarSync": {
diff --git a/react/features/breakout-rooms/actions.js b/react/features/breakout-rooms/actions.js
index c6652d7042..61d216461f 100644
--- a/react/features/breakout-rooms/actions.js
+++ b/react/features/breakout-rooms/actions.js
@@ -13,7 +13,11 @@ import {
} from '../base/conference';
import { setAudioMuted, setVideoMuted } from '../base/media';
import { getRemoteParticipants } from '../base/participants';
-import { clearNotifications } from '../notifications';
+import {
+ NOTIFICATION_TIMEOUT_TYPE,
+ clearNotifications,
+ showNotification
+} from '../notifications';
import { _RESET_BREAKOUT_ROOMS, _UPDATE_ROOM_COUNTER } from './actionTypes';
import { FEATURE_KEY } from './constants';
@@ -155,8 +159,9 @@ export function sendParticipantToRoom(participantId: string, roomId: string) {
* @returns {Function}
*/
export function moveToRoom(roomId?: string) {
- return (dispatch: Dispatch<any>, getState: Function) => {
- let _roomId = roomId || getMainRoom(getState)?.id;
+ return async (dispatch: Dispatch<any>, getState: Function) => {
+ const mainRoomId = getMainRoom(getState)?.id;
+ let _roomId = roomId || mainRoomId;
// Check if we got a full JID.
// $FlowExpectedError
@@ -175,6 +180,18 @@ export function moveToRoom(roomId?: string) {
_roomId.domain = domainParts.join('@');
}
+ // $FlowExpectedError
+ const roomIdStr = _roomId?.toString();
+ const goToMainRoom = roomIdStr === mainRoomId;
+ const rooms = getBreakoutRooms(getState);
+ const targetRoom = rooms[roomIdStr];
+
+ if (!targetRoom) {
+ logger.warn(`Unknown room: ${targetRoom}`);
+
+ return;
+ }
+
dispatch({
type: _RESET_BREAKOUT_ROOMS
});
@@ -185,23 +202,47 @@ export function moveToRoom(roomId?: string) {
dispatch(conferenceWillLeave(conference));
- conference.leave()
- .catch(error => {
- logger.warn('JitsiConference.leave() rejected with:', error);
+ try {
+ await conference.leave();
+ } catch (error) {
+ logger.warn('JitsiConference.leave() rejected with:', error);
- dispatch(conferenceLeft(conference));
- })
- .then(() => {
- dispatch(clearNotifications());
-
- // dispatch(setRoom(_roomId));
- dispatch(createConference(_roomId));
- dispatch(setAudioMuted(audio.muted));
- dispatch(setVideoMuted(video.muted));
- });
+ dispatch(conferenceLeft(conference));
+ }
+
+ dispatch(clearNotifications());
+
+ // dispatch(setRoom(_roomId));
+ dispatch(createConference(_roomId));
+ dispatch(setAudioMuted(audio.muted));
+ dispatch(setVideoMuted(video.muted));
+ } else {
+ try {
+ APP.conference.leaveRoom(false /* doDisconnect */);
+ } catch (error) {
+ logger.warn('APP.conference.leaveRoom() rejected with:', error);
+
+ // TODO: revisit why we don't dispatch CONFERENCE_LEFT here.
+ }
+
+ APP.conference.joinRoom(_roomId);
+ }
+
+ if (goToMainRoom) {
+ dispatch(showNotification({
+ titleKey: 'breakoutRooms.notifications.joinedTitle',
+ descriptionKey: 'breakoutRooms.notifications.joinedMainRoom',
+ concatText: true,
+ maxLines: 2
+ }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
} else {
- APP.conference.leaveRoom(false /* doDisconnect */)
- .finally(() => APP.conference.joinRoom(_roomId));
+ dispatch(showNotification({
+ titleKey: 'breakoutRooms.notifications.joinedTitle',
+ descriptionKey: 'breakoutRooms.notifications.joined',
+ descriptionArguments: { name: targetRoom.name },
+ concatText: true,
+ maxLines: 2
+ }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
}
};
}