feat(breakout-rooms) add notification when joining rooms
This commit is contained in:
parent
4401ea8818
commit
da0cb2b837
|
@ -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": {
|
||||
|
|
|
@ -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(conferenceLeft(conference));
|
||||
}
|
||||
|
||||
// dispatch(setRoom(_roomId));
|
||||
dispatch(createConference(_roomId));
|
||||
dispatch(setAudioMuted(audio.muted));
|
||||
dispatch(setVideoMuted(video.muted));
|
||||
});
|
||||
dispatch(clearNotifications());
|
||||
|
||||
// dispatch(setRoom(_roomId));
|
||||
dispatch(createConference(_roomId));
|
||||
dispatch(setAudioMuted(audio.muted));
|
||||
dispatch(setVideoMuted(video.muted));
|
||||
} else {
|
||||
APP.conference.leaveRoom(false /* doDisconnect */)
|
||||
.finally(() => APP.conference.joinRoom(_roomId));
|
||||
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 {
|
||||
dispatch(showNotification({
|
||||
titleKey: 'breakoutRooms.notifications.joinedTitle',
|
||||
descriptionKey: 'breakoutRooms.notifications.joined',
|
||||
descriptionArguments: { name: targetRoom.name },
|
||||
concatText: true,
|
||||
maxLines: 2
|
||||
}, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue