Fix re-enter + Cleanup
This commit is contained in:
parent
1264e70408
commit
68e66e2319
3 changed files with 9 additions and 16 deletions
|
@ -12,8 +12,8 @@ import Button from '../../atoms/button/Button';
|
||||||
|
|
||||||
const TOPIC_JITSI_CALL = 'd38dd491fefa1cfffc27f9c57f2bdb4a'
|
const TOPIC_JITSI_CALL = 'd38dd491fefa1cfffc27f9c57f2bdb4a'
|
||||||
|
|
||||||
function JitsiRoom(props) {
|
function JitsiRoom() {
|
||||||
const { jitsiCallId, setJitsiCallId } = props;
|
const [jitsiCallId, setJitsiCallId] = useState(null);
|
||||||
|
|
||||||
const [roomInfo, setRoomInfo] = useState({
|
const [roomInfo, setRoomInfo] = useState({
|
||||||
roomTimeline: null,
|
roomTimeline: null,
|
||||||
|
@ -31,12 +31,15 @@ function JitsiRoom(props) {
|
||||||
const roomTimeline = new RoomTimeline(rId);
|
const roomTimeline = new RoomTimeline(rId);
|
||||||
const topic = roomTimeline.room.currentState.getStateEvents('m.room.topic')[0]?.getContent().topic
|
const topic = roomTimeline.room.currentState.getStateEvents('m.room.topic')[0]?.getContent().topic
|
||||||
|
|
||||||
if (mx.getRoom(rId) && topic === TOPIC_JITSI_CALL) {
|
if (mx.getRoom(rId) && topic === TOPIC_JITSI_CALL && jitsiCallId !== rId) {
|
||||||
if (confirm('Do you want to join this call?')) {
|
if (confirm('Do you want to join this call?')) {
|
||||||
|
setJitsiCallId(rId);
|
||||||
|
setRoomName(roomTimeline.roomName);
|
||||||
setRoomInfo({
|
setRoomInfo({
|
||||||
roomTimeline,
|
roomTimeline,
|
||||||
eventId: eId ?? null,
|
eventId: eId ?? null,
|
||||||
});
|
});
|
||||||
|
setCounter(counter + 1);
|
||||||
} else if (!jitsiCallId) {
|
} else if (!jitsiCallId) {
|
||||||
setRoomInfo({
|
setRoomInfo({
|
||||||
roomTimeline: null,
|
roomTimeline: null,
|
||||||
|
@ -50,14 +53,6 @@ function JitsiRoom(props) {
|
||||||
return () => {
|
return () => {
|
||||||
navigation.removeListener(cons.events.navigation.ROOM_SELECTED, handleRoomSelected);
|
navigation.removeListener(cons.events.navigation.ROOM_SELECTED, handleRoomSelected);
|
||||||
};
|
};
|
||||||
}, [mx, roomInfo]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (roomInfo?.roomTimeline) {
|
|
||||||
setJitsiCallId(roomInfo.roomTimeline.roomId);
|
|
||||||
setRoomName(roomInfo.roomTimeline.roomName);
|
|
||||||
setCounter(counter + 1);
|
|
||||||
}
|
|
||||||
}, [roomInfo]);
|
}, [roomInfo]);
|
||||||
|
|
||||||
const { roomTimeline } = roomInfo;
|
const { roomTimeline } = roomInfo;
|
||||||
|
|
|
@ -12,9 +12,8 @@ import Welcome from '../welcome/Welcome';
|
||||||
import RoomView from './RoomView';
|
import RoomView from './RoomView';
|
||||||
import RoomSettings from './RoomSettings';
|
import RoomSettings from './RoomSettings';
|
||||||
import PeopleDrawer from './PeopleDrawer';
|
import PeopleDrawer from './PeopleDrawer';
|
||||||
import Button from '../../atoms/button/Button';
|
|
||||||
|
|
||||||
function Room(props) {
|
function Room() {
|
||||||
const [roomInfo, setRoomInfo] = useState({
|
const [roomInfo, setRoomInfo] = useState({
|
||||||
roomTimeline: null,
|
roomTimeline: null,
|
||||||
eventId: null,
|
eventId: null,
|
||||||
|
|
|
@ -27,7 +27,6 @@ function Client() {
|
||||||
const [isLoading, changeLoading] = useState(true);
|
const [isLoading, changeLoading] = useState(true);
|
||||||
const [loadingMsg, setLoadingMsg] = useState('Heating up');
|
const [loadingMsg, setLoadingMsg] = useState('Heating up');
|
||||||
const [dragCounter, setDragCounter] = useState(0);
|
const [dragCounter, setDragCounter] = useState(0);
|
||||||
const [jitsiCallId, setJitsiCallId] = useState(null);
|
|
||||||
const classNameHidden = 'client__item-hidden';
|
const classNameHidden = 'client__item-hidden';
|
||||||
|
|
||||||
const navWrapperRef = useRef(null);
|
const navWrapperRef = useRef(null);
|
||||||
|
@ -171,13 +170,13 @@ function Client() {
|
||||||
onDrop={handleDrop}
|
onDrop={handleDrop}
|
||||||
>
|
>
|
||||||
<div className="jitsi_room__wrapper">
|
<div className="jitsi_room__wrapper">
|
||||||
<JitsiRoom jitsiCallId={jitsiCallId} setJitsiCallId={setJitsiCallId} />
|
<JitsiRoom />
|
||||||
</div>
|
</div>
|
||||||
<div className="navigation__wrapper" ref={navWrapperRef}>
|
<div className="navigation__wrapper" ref={navWrapperRef}>
|
||||||
<Navigation />
|
<Navigation />
|
||||||
</div>
|
</div>
|
||||||
<div className={`room__wrapper ${classNameHidden}`} ref={roomWrapperRef}>
|
<div className={`room__wrapper ${classNameHidden}`} ref={roomWrapperRef}>
|
||||||
<Room jitsiCallId={jitsiCallId} setJitsiCallId={setJitsiCallId} />
|
<Room />
|
||||||
</div>
|
</div>
|
||||||
<Windows />
|
<Windows />
|
||||||
<Dialogs />
|
<Dialogs />
|
||||||
|
|
Loading…
Reference in a new issue