From 6bd9865bd398885138e3ae8608e378cc2ba4d0b9 Mon Sep 17 00:00:00 2001 From: Doron Nahari Date: Wed, 30 Sep 2020 01:30:38 +0300 Subject: [PATCH] Fix progress notification issues Signed-off-by: Doron Nahari --- CHANGELOG.md | 4 ++++ packages/core/src/common/message-service-protocol.ts | 4 +--- .../messages/src/browser/notifications-manager.ts | 11 ++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0afc655d92fdf..9f3d6b8259fb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - [scm] show in the commit textbox the branch to which the commit will go [#6156](https://github.com/eclipse-theia/theia/pull/6156) +[Breaking Changes:](#breaking_changes_1.7.0) + +- [core] change progress notification cancelable property default from true to false [#8479](https://github.com/eclipse-theia/theia/pull/8479) +- [messages] empty notifications and progress notifications will not be shown [#8479](https://github.com/eclipse-theia/theia/pull/8479) ## v1.6.0 - 24/09/2020 diff --git a/packages/core/src/common/message-service-protocol.ts b/packages/core/src/common/message-service-protocol.ts index 277edb66059d8..526984fce7ed9 100644 --- a/packages/core/src/common/message-service-protocol.ts +++ b/packages/core/src/common/message-service-protocol.ts @@ -42,9 +42,7 @@ export interface ProgressMessage extends Message { export namespace ProgressMessage { export const Cancel = 'Cancel'; export function isCancelable(message: ProgressMessage): boolean { - return !message.options - || message.options.cancelable === undefined - || message.options.cancelable === true; + return !!message.options && !!message.options.cancelable; } } diff --git a/packages/messages/src/browser/notifications-manager.ts b/packages/messages/src/browser/notifications-manager.ts index 2c0f7b00fd752..c2f52c5181a24 100644 --- a/packages/messages/src/browser/notifications-manager.ts +++ b/packages/messages/src/browser/notifications-manager.ts @@ -66,8 +66,12 @@ export class NotificationManager extends MessageClient { protected readonly onUpdatedEmitter = new Emitter(); readonly onUpdated = this.onUpdatedEmitter.event; protected readonly fireUpdatedEvent = throttle(() => { - const notifications = deepClone(Array.from(this.notifications.values())); - const toasts = deepClone(Array.from(this.toasts.values())); + const notifications = deepClone(Array.from(this.notifications.values()).filter((notification: Notification) => + notification.message + )); + const toasts = deepClone(Array.from(this.toasts.values()).filter((toast: Notification) => + toast.message + )); const visibilityState = this.visibilityState; this.onUpdatedEmitter.fire({ notifications, toasts, visibilityState }); }, 250, { leading: true, trailing: true }); @@ -269,7 +273,8 @@ export class NotificationManager extends MessageClient { if (cancellationToken.isCancellationRequested) { this.clear(messageId); } else { - notification.message = update.message ? `${originalMessage.text}: ${update.message}` : originalMessage.text; + notification.message = originalMessage.text && update.message ? `${originalMessage.text}: ${update.message}` : + originalMessage.text || update?.message || notification.message; notification.progress = this.toPlainProgress(update); } this.fireUpdatedEvent();