Skip to content

Commit

Permalink
Merge pull request #63136 from Microsoft/joh/fix-leak2
Browse files Browse the repository at this point in the history
add focus change listener once
  • Loading branch information
jrieken authored Nov 15, 2018
2 parents 70b33c4 + 43712d3 commit e074335
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ export class NotificationsToasts extends Themable {

// Install Timers to Purge Notification
let purgeTimeoutHandle: any;
let listener: IDisposable;

const hideAfterTimeout = () => {

purgeTimeoutHandle = setTimeout(() => {

// If the notification is sticky or prompting and the window does not have
Expand All @@ -220,11 +223,14 @@ export class NotificationsToasts extends Themable {
// could immediately hide the notification because the timeout was triggered
// again.
if ((item.sticky || item.hasPrompt()) && !this.windowHasFocus) {
disposables.push(this.windowService.onDidChangeFocus(focus => {
if (focus) {
hideAfterTimeout();
}
}));
if (!listener) {
listener = this.windowService.onDidChangeFocus(focus => {
if (focus) {
hideAfterTimeout();
}
});
disposables.push(listener);
}
}

// Otherwise...
Expand Down Expand Up @@ -509,4 +515,4 @@ export class NotificationsToasts extends Themable {
private isVisible(toast: INotificationToast): boolean {
return !!toast.container.parentElement;
}
}
}

0 comments on commit e074335

Please sign in to comment.