Skip to content

Commit 49c6645

Browse files
committed
fix(game-stream): ignore clear stream events except for the primary stream
1 parent 00d5f58 commit 49c6645

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

electron/renderer/components/game/game-stream.tsx

+19-7
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,19 @@ export interface GameStreamProps {
1717
* The special log line text '__CLEAR_STREAM__' will clear all prior lines.
1818
*/
1919
stream$: rxjs.Observable<GameLogLine>;
20+
/**
21+
* The primary stream id that this component should display.
22+
* If other streams are redirected to this stream, only the "clear stream"
23+
* events for the primary stream will be honored, otherwise the stream
24+
* may be cleared too often.
25+
*/
26+
primaryStreamId: string;
2027
/**
2128
* The list of game stream ids that this component should display.
22-
* Most components will only display a single stream id.
29+
* Most components will only display their primary stream id,
30+
* but players may redirect streams to another to reduce the number
31+
* of stream windows they need open. For example, to redirect the
32+
* 'assess' and 'combat' streams to the 'main' primary stream.
2333
*/
2434
gameStreamIds: Array<string>;
2535
/**
@@ -33,7 +43,7 @@ export interface GameStreamProps {
3343
export const GameStream: React.FC<GameStreamProps> = (
3444
props: GameStreamProps
3545
): ReactNode => {
36-
const { stream$, gameStreamIds, maxLines = 500 } = props;
46+
const { stream$, primaryStreamId, gameStreamIds, maxLines = 500 } = props;
3747

3848
const filteredStream$ = useObservable(() => {
3949
return stream$.pipe(
@@ -73,11 +83,13 @@ export const GameStream: React.FC<GameStreamProps> = (
7383
// We use `setTimeout` because browser doesn't have `setImmediate`.
7484
setTimeout(() => {
7585
if (logLine.text === '__CLEAR_STREAM__') {
76-
// Clear the stream after a short delay to prevent flickering
77-
// caused by a flash of empty content then the new content.
78-
clearStreamTimeoutRef.current = setTimeout(() => {
79-
setGameLogLines([]);
80-
}, 1000);
86+
if (logLine.streamId === primaryStreamId) {
87+
// Clear the stream after a short delay to prevent flickering
88+
// caused by a flash of empty content then the new content.
89+
clearStreamTimeoutRef.current = setTimeout(() => {
90+
setGameLogLines([]);
91+
}, 1000);
92+
}
8193
} else {
8294
// If we receieved a new log line, cancel any pending clear stream.
8395
// Set the game log lines to the new log line to prevent flickering.

0 commit comments

Comments
 (0)