提交 588799d1 编写于 作者: B Benjamin Pasero

notifications - tweak purge timeout behaviour

上级 7864e57a
......@@ -210,16 +210,23 @@ export class NotificationsToasts extends Themable {
disposables.push(addDisposableListener(notificationToastContainer, EventType.MOUSE_OUT, () => isMouseOverToast = false));
// Install Timers
let timeoutHandle: any;
let purgeTimeoutHandle: any;
let pendingPurgeTimeoutHandle: any;
const hideAfterTimeout = () => {
timeoutHandle = setTimeout(() => {
purgeTimeoutHandle = setTimeout(() => {
if (
item.sticky || // never hide sticky notifications
notificationList.hasFocus() || // never hide notifications with focus
isMouseOverToast || // never hide notifications under mouse
!this.windowHasFocus // never hide when window has no focus
) {
hideAfterTimeout();
// If the notification should not be hidden yet for the reasons outlined
// above, we delay an additional check by at least PURGE_TIMEOUT so that
// if the condition changes to hide the notification, the timeout will
// be at least PURGE_TIMEOUT (+ the time it took to change the state)
pendingPurgeTimeoutHandle = setTimeout(() => {
hideAfterTimeout();
}, NotificationsToasts.PURGE_TIMEOUT[item.severity]);
} else {
this.removeToast(item);
}
......@@ -228,7 +235,8 @@ export class NotificationsToasts extends Themable {
hideAfterTimeout();
disposables.push(toDisposable(() => clearTimeout(timeoutHandle)));
disposables.push(toDisposable(() => clearTimeout(purgeTimeoutHandle)));
disposables.push(toDisposable(() => clearTimeout(pendingPurgeTimeoutHandle)));
}
private removeToast(item: INotificationViewItem): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册