Skip to content

Commit

Permalink
Merge pull request #331 from phiter/fix/#222-invite-to-external-url
Browse files Browse the repository at this point in the history
fix(office): fixes user invitation to external meeting opening jitsi instead
  • Loading branch information
juliemar authored Jun 8, 2020
2 parents adcec6a + 86c8ef6 commit e1643e4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 29 deletions.
2 changes: 1 addition & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed

### Changed

- fixed behavior when inviting user to external meeting, now matrix will not open a new jitsi room
## [2.0.1] 2020-05-05
### Added
- New `ctrl+click` to open a embeded Jitsi Meet in a new Tab.
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/morpheus/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { withRouter } from "react-router-dom";
import { connect } from "react-redux";
import { useSnackbar } from "notistack";
import PropTypes from "prop-types";

import { enterRoom } from "./containers/OfficePage";
import Loading from "../components/Loading";
import PageLayout from "../components/PageLayout";
import MenuUsers from "../components/MenuUsers";
Expand Down Expand Up @@ -163,7 +163,8 @@ const MorpheusApp = ({
receiveInviteAudio.pause();
setReceiveInviteAudio(null);
}
history.push(`/morpheus/room/${invitation.room.id}`);
onSetCurrentRoom(invitation.room);
enterRoom(invitation.room, history);
}}
/>
<MessageDialog />
Expand Down
58 changes: 32 additions & 26 deletions frontend/src/morpheus/containers/OfficePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,36 @@ import { emitEnterInRoom, emitStartMeeting, emitLeftMeeting} from "../socket";
import { setCurrentRoom } from "../store/actions";
import { CurrentRoomPropType } from "../store/models";

const externalMeetRoomMonitoring = (externalMeetRoom) => {
const interval = window.setInterval(() => {
if (!externalMeetRoom.closed) return;

emitLeftMeeting();
window.clearInterval(interval);
}, 1000);
};

const startMeeting = (redirectUrl, history, openInNewTab = false) => {
if (openInNewTab) {
window.open(redirectUrl, "_blank");
} else {
history.push(redirectUrl);
}
};

export const enterRoom = (room, history, openInNewTab = false) => {
emitEnterInRoom(room.id);

if(room.externalMeetUrl) {
emitStartMeeting();
const externalMeetRoom = window.open(room.externalMeetUrl);

externalMeetRoomMonitoring(externalMeetRoom);
} else {
startMeeting(`/morpheus/room/${room.id}`, history, openInNewTab);
}
};

const useStyles = makeStyles(theme => ({
root: {
padding: theme.spacing(3)
Expand Down Expand Up @@ -54,33 +84,9 @@ const OfficePage = ({
history.replace(`/morpheus/office/${room.id}`);
}}
onEnterMeeting={(event) => {
emitEnterInRoom(room.id);
onSetCurrentRoom(room);

if(room.externalMeetUrl){
emitStartMeeting();
const externalMeetRoom = window.open(room.externalMeetUrl);

const externalMeetRoomMonitoring = () => {
window.setTimeout(() => {
if (externalMeetRoom.closed) {
emitLeftMeeting();
}else{
externalMeetRoomMonitoring();
}
}, 1000);
}

externalMeetRoomMonitoring();

}else{
const redirectUrl = `/morpheus/room/${room.id}`;
if (event.ctrlKey) {
window.open(redirectUrl, "_blank");
} else {
history.push(redirectUrl);
}
}
const openInNewTab = event.ctrlKey
enterRoom(room, history, openInNewTab);
}}
/>
))}
Expand Down

0 comments on commit e1643e4

Please sign in to comment.