diff --git a/src/ConferenceCallManager.js b/src/ConferenceCallManager.js index ca54d9d6..4b028dde 100644 --- a/src/ConferenceCallManager.js +++ b/src/ConferenceCallManager.js @@ -188,7 +188,7 @@ export class ConferenceCallManager extends EventEmitter { if (type.startsWith("m.call.") || type.startsWith("me.robertlong.conf")) { const content = event.getContent(); - const details = {}; + const details = { content }; switch (type) { case "m.call.invite": diff --git a/src/DevTools.jsx b/src/DevTools.jsx index 49775bfe..39174096 100644 --- a/src/DevTools.jsx +++ b/src/DevTools.jsx @@ -4,6 +4,16 @@ import styles from "./DevTools.module.css"; const colorHash = new ColorHash({ lightness: 0.8 }); +function UserId({ userId, ...rest }) { + const shortUserId = userId.split(":")[0]; + const color = colorHash.hex(shortUserId); + return ( + + {shortUserId} + + ); +} + function CallId({ callId, ...rest }) { const shortId = callId.substr(callId.length - 16); const color = colorHash.hex(shortId); @@ -17,6 +27,7 @@ function CallId({ callId, ...rest }) { export function DevTools({ manager }) { const [debugState, setDebugState] = useState(manager.debugState); + const [selectedEvent, setSelectedEvent] = useState(); useEffect(() => { function onRoomDebug() { @@ -33,13 +44,24 @@ export function DevTools({ manager }) { return (
{Array.from(debugState.entries()).map(([userId, props]) => ( - + ))} + {selectedEvent && ( + setSelectedEvent(null)} + /> + )}
); } -function UserState({ userId, state, callId, events }) { +function UserState({ userId, state, callId, events, onSelectEvent }) { const eventsRef = useRef(); const [autoScroll, setAutoScroll] = useState(true); @@ -50,7 +72,7 @@ function UserState({ userId, state, callId, events }) { } }); - const onScroll = useCallback((event) => { + const onScroll = useCallback(() => { const el = eventsRef.current; if (el.scrollHeight - el.scrollTop === el.clientHeight) { @@ -63,13 +85,17 @@ function UserState({ userId, state, callId, events }) { return (
- {userId} - {callId && } + {`(${state})`} + {callId && }
{events.map((event, idx) => ( -
+
onSelectEvent(event)} + > {event.type} {event.callId && ( @@ -84,7 +110,7 @@ function UserState({ userId, state, callId, events }) { )} {event.to && ( - {event.to} + )} {event.reason && ( {event.reason} @@ -95,3 +121,41 @@ function UserState({ userId, state, callId, events }) {
); } + +function EventViewer({ event, onClose }) { + return ( +
+

Event Type: {event.type}

+ {event.callId && ( +

+ Call Id: +

+ )} + {event.newCallId && ( +

+ New Call Id: + +

+ )} + {event.to && ( +

+ To: +

+ )} + {event.reason && ( +

+ Reason: {event.reason} +

+ )} + {event.content && ( + <> +

Content:

+
+            {JSON.stringify(event.content, undefined, 2)}
+          
+ + )} + +
+ ); +} diff --git a/src/DevTools.module.css b/src/DevTools.module.css index 2a18ef3f..7aa4a672 100644 --- a/src/DevTools.module.css +++ b/src/DevTools.module.css @@ -67,4 +67,23 @@ .eventDetails { font-weight: 200; word-break: break-all; +} + +.eventViewer { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + min-width: 320px; + max-width: 80%; + border-radius: 8px; + border: 1px solid black; + background-color: #222; + padding: 20px; + margin: 20px; +} + +.eventViewer .content { + max-height: 200px; + overflow: auto; } \ No newline at end of file