Skip to content

Commit

Permalink
Always resolve existing before showing new notification (#13668)
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew authored Jun 20, 2024
1 parent 7767e54 commit c2be137
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions packages/messages/src/browser/notifications-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,23 @@ export class NotificationManager extends MessageClient {
override showMessage(plainMessage: PlainMessage): Promise<string | undefined> {
const messageId = this.getMessageId(plainMessage);

let notification = this.notifications.get(messageId);
if (!notification) {
const message = this.contentRenderer.renderMessage(plainMessage.text);
const type = this.toNotificationType(plainMessage.type);
const actions = Array.from(new Set(plainMessage.actions));
const source = plainMessage.source;
const expandable = this.isExpandable(message, source, actions);
const collapsed = expandable;
notification = { messageId, message, type, actions, expandable, collapsed };
this.notifications.set(messageId, notification);
this.toasts.delete(messageId);
this.notifications.delete(messageId);
const existingDeferred = this.deferredResults.get(messageId);
if (existingDeferred) {
this.deferredResults.delete(messageId);
existingDeferred.resolve(undefined);
}
const result = this.deferredResults.get(messageId) || new Deferred<string | undefined>();

const message = this.contentRenderer.renderMessage(plainMessage.text);
const type = this.toNotificationType(plainMessage.type);
const actions = Array.from(new Set(plainMessage.actions));
const source = plainMessage.source;
const expandable = this.isExpandable(message, source, actions);
const collapsed = expandable;
const notification = { messageId, message, type, actions, expandable, collapsed };
this.notifications.set(messageId, notification);
const result = new Deferred<string | undefined>();
this.deferredResults.set(messageId, result);

if (!this.centerVisible) {
Expand Down

0 comments on commit c2be137

Please sign in to comment.