mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 10:24:47 +00:00
only add focus change listener once
This commit is contained in:
parent
e2f8c3c404
commit
aa4ef3a42c
1 changed files with 12 additions and 6 deletions
|
@ -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
|
||||
|
@ -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...
|
||||
|
@ -509,4 +515,4 @@ export class NotificationsToasts extends Themable {
|
|||
private isVisible(toast: INotificationToast): boolean {
|
||||
return !!toast.container.parentElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue