mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
web: pop-out window opens channel streams by itself
While the stream grid is popped out, every stream in our channel is watched right away instead of showing a "Watch" tile. Each stream is auto-opened only once, so closing it or a refused join request leaves the tile rather than rejoining in a loop. The main window still waits for a click. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
e923181e14
commit
fc33843179
1 file changed
+16
@@ -9074,6 +9074,8 @@ function AppInner() {
|
|||||||
/** Keyed by stream id: one client can send screen and camera at once. */
|
/** Keyed by stream id: one client can send screen and camera at once. */
|
||||||
const [watchedStreams, setWatchedStreams] = useState<Record<string, WatchedStream>>({});
|
const [watchedStreams, setWatchedStreams] = useState<Record<string, WatchedStream>>({});
|
||||||
const streamViewersRef = useRef<Map<string, StreamViewer>>(new Map());
|
const streamViewersRef = useRef<Map<string, StreamViewer>>(new Map());
|
||||||
|
/** Streams the pop-out already opened by itself; closed or refused ones are not retried. */
|
||||||
|
const autoWatchedRef = useRef<Set<string>>(new Set());
|
||||||
/** Tile shown across the whole grid, Discord's "focus" (clid, or -1 for our own broadcast). */
|
/** Tile shown across the whole grid, Discord's "focus" (clid, or -1 for our own broadcast). */
|
||||||
const [focusedStream, setFocusedStream] = useState<string | null>(null);
|
const [focusedStream, setFocusedStream] = useState<string | null>(null);
|
||||||
/** Separate browser window the stream grid is portalled into, if popped out. */
|
/** Separate browser window the stream grid is portalled into, if popped out. */
|
||||||
@@ -12294,6 +12296,20 @@ function AppInner() {
|
|||||||
viewer.join();
|
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. */
|
/** Stops one broadcast, or all of them without a source. */
|
||||||
const handleStopPublishing = (source?: PublishSource) => {
|
const handleStopPublishing = (source?: PublishSource) => {
|
||||||
const publishers = publishersRef.current;
|
const publishers = publishersRef.current;
|
||||||
|
|||||||
Reference in new issue
Block a user