diff --git a/apps/desktop/src/main/services/notification-service.ts b/apps/desktop/src/main/services/notification-service.ts index 5a84a6a8..335ee4c3 100644 --- a/apps/desktop/src/main/services/notification-service.ts +++ b/apps/desktop/src/main/services/notification-service.ts @@ -16,6 +16,10 @@ export class NotificationService { eventBus.subscribe((event) => { if (event.type === 'radar_data_updated') { this.checkBadge(); + } else if (event.type === 'workspace_deleted') { + this.checkBadge(); + } else if (event.type === 'account_deleted') { + this.checkBadge(); } }); } diff --git a/apps/desktop/src/main/services/workspaces/radar-service.ts b/apps/desktop/src/main/services/workspaces/radar-service.ts index 01b1f09a..92fd94d2 100644 --- a/apps/desktop/src/main/services/workspaces/radar-service.ts +++ b/apps/desktop/src/main/services/workspaces/radar-service.ts @@ -27,10 +27,11 @@ export class RadarService { private readonly workspace: WorkspaceService; private readonly unreadMessages: Map = new Map(); private readonly collaborations: Map = new Map(); + private readonly eventSubscriptionId: string; constructor(workspace: WorkspaceService) { this.workspace = workspace; - eventBus.subscribe(this.handleEvent.bind(this)); + this.eventSubscriptionId = eventBus.subscribe(this.handleEvent.bind(this)); } public getData(): WorkspaceRadarData { @@ -128,6 +129,10 @@ export class RadarService { } } + public destroy(): void { + eventBus.unsubscribe(this.eventSubscriptionId); + } + private async handleEvent(event: Event) { if (event.type === 'message_interaction_updated') { await this.handleMessageInteractionUpdated(event); diff --git a/apps/desktop/src/main/services/workspaces/workspace-service.ts b/apps/desktop/src/main/services/workspaces/workspace-service.ts index 89bbf6de..b67f5073 100644 --- a/apps/desktop/src/main/services/workspaces/workspace-service.ts +++ b/apps/desktop/src/main/services/workspaces/workspace-service.ts @@ -125,6 +125,7 @@ export class WorkspaceService { this.synchronizer.destroy(); this.files.destroy(); this.mutations.destroy(); + this.radar.destroy(); const workspacePath = getWorkspaceDirectoryPath( this.account.id,