Add destroy method for radar service

This commit is contained in:
Hakan Shehu
2025-01-18 01:31:20 +01:00
parent 6ffa9c96e8
commit c6ad50e3ec
3 changed files with 11 additions and 1 deletions

View File

@@ -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();
}
});
}

View File

@@ -27,10 +27,11 @@ export class RadarService {
private readonly workspace: WorkspaceService;
private readonly unreadMessages: Map<string, UndreadMessage> = new Map();
private readonly collaborations: Map<string, SelectCollaboration> = 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);

View File

@@ -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,