@@ -17,9 +17,19 @@ export interface GameStreamProps {
17
17
* The special log line text '__CLEAR_STREAM__' will clear all prior lines.
18
18
*/
19
19
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 ;
20
27
/**
21
28
* 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.
23
33
*/
24
34
gameStreamIds : Array < string > ;
25
35
/**
@@ -33,7 +43,7 @@ export interface GameStreamProps {
33
43
export const GameStream : React . FC < GameStreamProps > = (
34
44
props : GameStreamProps
35
45
) : ReactNode => {
36
- const { stream$, gameStreamIds, maxLines = 500 } = props ;
46
+ const { stream$, primaryStreamId , gameStreamIds, maxLines = 500 } = props ;
37
47
38
48
const filteredStream$ = useObservable ( ( ) => {
39
49
return stream$ . pipe (
@@ -73,11 +83,13 @@ export const GameStream: React.FC<GameStreamProps> = (
73
83
// We use `setTimeout` because browser doesn't have `setImmediate`.
74
84
setTimeout ( ( ) => {
75
85
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
+ }
81
93
} else {
82
94
// If we receieved a new log line, cancel any pending clear stream.
83
95
// Set the game log lines to the new log line to prevent flickering.
0 commit comments