diff --git a/web/src/App.tsx b/web/src/App.tsx index 60ab22b..712c74c 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -9074,6 +9074,8 @@ function AppInner() { /** Keyed by stream id: one client can send screen and camera at once. */ const [watchedStreams, setWatchedStreams] = useState>({}); const streamViewersRef = useRef>(new Map()); + /** Streams the pop-out already opened by itself; closed or refused ones are not retried. */ + const autoWatchedRef = useRef>(new Set()); /** Tile shown across the whole grid, Discord's "focus" (clid, or -1 for our own broadcast). */ const [focusedStream, setFocusedStream] = useState(null); /** Separate browser window the stream grid is portalled into, if popped out. */ @@ -12294,6 +12296,20 @@ function AppInner() { viewer.join(); }; + // Popped out, the window is meant for watching: open channel streams right + // away. Only once per stream, so closing one (or a refused join request) + // leaves a tile to click instead of reopening it in a loop. + const availableStreamIds = availableStreams.map((info) => info.id).join(","); + useEffect(() => { + if (!streamPopout) return; + for (const info of availableStreams) { + if (autoWatchedRef.current.has(info.id)) continue; + autoWatchedRef.current.add(info.id); + handleWatchStream(info.id); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [streamPopout, availableStreamIds]); + /** Stops one broadcast, or all of them without a source. */ const handleStopPublishing = (source?: PublishSource) => { const publishers = publishersRef.current;