Fix space name in jitsi room header

This commit is contained in:
CrazyStevenz 2023-03-25 22:43:25 +02:00
parent 70e9d9254d
commit 59375f02b8

View file

@ -13,7 +13,7 @@ import { getUsername } from '../../../util/matrixUtil';
import Button from '../../atoms/button/Button'; import Button from '../../atoms/button/Button';
import { useSelectedSpace } from '../../hooks/useSelectedSpace'; import { useSelectedSpace } from '../../hooks/useSelectedSpace';
const TOPIC_JITSI_CALL = 'd38dd491fefa1cfffc27f9c57f2bdb4a' const TOPIC_JITSI_CALL = 'd38dd491fefa1cfffc27f9c57f2bdb4a';
function JitsiRoom({ isJitsiRoom, setIsJitsiRoom, jitsiCallId, setJitsiCallId }) { function JitsiRoom({ isJitsiRoom, setIsJitsiRoom, jitsiCallId, setJitsiCallId }) {
const [roomInfo, setRoomInfo] = useState({ const [roomInfo, setRoomInfo] = useState({
@ -21,11 +21,11 @@ function JitsiRoom({ isJitsiRoom, setIsJitsiRoom, jitsiCallId, setJitsiCallId })
eventId: null, eventId: null,
}); });
const [roomName, setRoomName] = useState(''); const [roomName, setRoomName] = useState('');
const [spaceName, setSpaceName] = useState(null);
const [counter, setCounter] = useState(0); const [counter, setCounter] = useState(0);
const openerRef = useRef(null);
const mx = initMatrix.matrixClient; const mx = initMatrix.matrixClient;
const spaceName = mx.getRoom(useSelectedSpace())?.name; const sn = mx.getRoom(useSelectedSpace())?.name;
useEffect(() => { useEffect(() => {
const handleRoomSelected = (rId, pRoomId, eId) => { const handleRoomSelected = (rId, pRoomId, eId) => {
@ -43,20 +43,19 @@ function JitsiRoom({ isJitsiRoom, setIsJitsiRoom, jitsiCallId, setJitsiCallId })
if (topic === TOPIC_JITSI_CALL && jitsiCallId !== rId) { if (topic === TOPIC_JITSI_CALL && jitsiCallId !== rId) {
setJitsiCallId(rId); setJitsiCallId(rId);
setRoomName(roomTimeline.roomName); setRoomName(roomTimeline.roomName);
setSpaceName(sn);
setRoomInfo({ setRoomInfo({
roomTimeline, roomTimeline,
eventId: eId ?? null, eventId: eId ?? null,
}); });
setCounter(counter + 1); setCounter(counter + 1);
} } else if (!jitsiCallId) {
else if (!jitsiCallId) {
setRoomInfo({ setRoomInfo({
roomTimeline: null, roomTimeline: null,
eventId: null, eventId: null,
}); });
} }
setIsJitsiRoom(topic === TOPIC_JITSI_CALL); setIsJitsiRoom(topic === TOPIC_JITSI_CALL);
}; };
@ -76,13 +75,14 @@ function JitsiRoom({ isJitsiRoom, setIsJitsiRoom, jitsiCallId, setJitsiCallId })
return ( return (
<Draggable disabled={isJitsiRoom}> <Draggable disabled={isJitsiRoom}>
<div className={isJitsiRoom ? 'call reset_pip' : 'call'}> <div className={isJitsiRoom ? 'call reset_pip' : 'call'}>
<div className={isJitsiRoom ? 'call_header' : 'call_header pip_header'} ref={openerRef}> <div className={isJitsiRoom ? 'call_header' : 'call_header pip_header'}>
{roomName} ({spaceName}) {roomName} ({spaceName || sn})
<div className="call_buttons"> <div className="call_buttons">
<Button <Button
onClick={() => { onClick={() => {
setJitsiCallId(null); setJitsiCallId(null);
setRoomName(''); setRoomName('');
setSpaceName(null);
setRoomInfo({ setRoomInfo({
roomTimeline: null, roomTimeline: null,
eventId: null, eventId: null,
@ -98,7 +98,7 @@ function JitsiRoom({ isJitsiRoom, setIsJitsiRoom, jitsiCallId, setJitsiCallId })
<JitsiMeeting <JitsiMeeting
key={counter} key={counter}
domain="meet.calyx.net" domain="meet.calyx.net"
roomName={`${roomName.replace(':', '')} ${spaceName?.replace( roomName={`${roomName.replace(':', '')} ${(spaceName || sn)?.replace(
':', ':',
'' ''
)} ${roomTimeline.roomId.replace(':matrix.org', '')}`} )} ${roomTimeline.roomId.replace(':matrix.org', '')}`}