@@ -20,6 +20,12 @@ type Updater = {
2020export class RunStore extends EventEmitter < RunStoreEvent > {
2121 private runs = new Map < number , WorkflowRun > ( ) ;
2222 private updaters = new Map < number , Updater > ( ) ;
23+ private _isFocused = true ;
24+
25+ setFocused ( focused : boolean ) {
26+ this . _isFocused = focused ;
27+ logDebug ( `[Store]: Focus state changed to ${ focused } ` ) ;
28+ }
2329
2430 getRun ( runId : number ) : WorkflowRun | undefined {
2531 return this . runs . get ( runId ) ;
@@ -66,6 +72,10 @@ export class RunStore extends EventEmitter<RunStoreEvent> {
6672 }
6773
6874 private async fetchRun ( updater : Updater ) {
75+ if ( ! this . _isFocused ) {
76+ return ;
77+ }
78+
6979 log ( `Fetching run update: ${ updater . runId } . Remaining attempts: ${ updater . remainingAttempts } ` ) ;
7080
7181 updater . remainingAttempts -- ;
@@ -87,7 +97,14 @@ export class RunStore extends EventEmitter<RunStoreEvent> {
8797 log ( `Polled run: ${ run . id } Status: ${ run . status } Conclusion: ${ run . conclusion } ` ) ;
8898 this . addRun ( updater . repoContext , run ) ;
8999
90- if ( run . status === "completed" || run . status === "cancelled" || run . status === "failure" || run . status === "success" || run . status === "skipped" || run . status === "timed_out" ) {
100+ if (
101+ run . status === "completed" ||
102+ run . status === "cancelled" ||
103+ run . status === "failure" ||
104+ run . status === "success" ||
105+ run . status === "skipped" ||
106+ run . status === "timed_out"
107+ ) {
91108 if ( updater . handle ) {
92109 clearInterval ( updater . handle ) ;
93110 }
0 commit comments