Skip to content

Commit b01febe

Browse files
committed
fix(integrations): run focus handler inside NgZone so UI updates without requiring a button click
1 parent fc07fa1 commit b01febe

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/app/components/workspace-integrations/workspace-integrations.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CommonModule } from '@angular/common';
2-
import { Component, Input, OnInit, OnDestroy, OnChanges, SimpleChanges, inject } from '@angular/core';
2+
import { Component, Input, NgZone, OnInit, OnDestroy, OnChanges, SimpleChanges, inject } from '@angular/core';
33
import { ActivatedRoute } from '@angular/router';
44
import { finalize } from 'rxjs';
55
import { IntegrationService } from '../../services/integration.service';
@@ -20,6 +20,7 @@ export class WorkspaceIntegrationsComponent implements OnInit, OnChanges, OnDest
2020

2121
private readonly route = inject(ActivatedRoute);
2222
private readonly integrationService = inject(IntegrationService);
23+
private readonly ngZone = inject(NgZone);
2324

2425
workspaceId = '';
2526
slackChannels: SlackChannel[] = [];
@@ -83,12 +84,15 @@ export class WorkspaceIntegrationsComponent implements OnInit, OnChanges, OnDest
8384
}
8485

8586
private onWindowFocus = (): void => {
86-
// Always reload integrations when the tab regains focus so that OAuth
87-
// connections completed in another tab/window are picked up immediately.
88-
this.slackFeedbackMessage = this.slackFeedbackMessage === 'Starting Slack connection...' ? '' : this.slackFeedbackMessage;
89-
this.githubFeedbackMessage = this.githubFeedbackMessage === 'Starting GitHub connection...' ? '' : this.githubFeedbackMessage;
90-
this.jiraFeedbackMessage = this.jiraFeedbackMessage === 'Starting Jira connection...' ? '' : this.jiraFeedbackMessage;
91-
this.loadAllIntegrations();
87+
// window events fire outside Angular's zone, so we must re-enter the zone
88+
// to trigger change detection immediately (clears the "Starting..." banner
89+
// and shows the newly-connected integration without needing a button click).
90+
this.ngZone.run(() => {
91+
this.slackFeedbackMessage = this.slackFeedbackMessage === 'Starting Slack connection...' ? '' : this.slackFeedbackMessage;
92+
this.githubFeedbackMessage = this.githubFeedbackMessage === 'Starting GitHub connection...' ? '' : this.githubFeedbackMessage;
93+
this.jiraFeedbackMessage = this.jiraFeedbackMessage === 'Starting Jira connection...' ? '' : this.jiraFeedbackMessage;
94+
this.loadAllIntegrations();
95+
});
9296
};
9397

9498
private loadAllIntegrations(): void {

0 commit comments

Comments
 (0)