Skip to content

Commit 110bbf1

Browse files
committed
add dispose logic for integration storage
1 parent 1dc510b commit 110bbf1

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/notebooks/deepnote/integrations/integrationStorage.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { inject, injectable } from 'inversify';
22
import { EventEmitter } from 'vscode';
33

44
import { IEncryptedStorage } from '../../../platform/common/application/types';
5+
import { IAsyncDisposableRegistry } from '../../../platform/common/types';
56
import { logger } from '../../../platform/logging';
67
import { IntegrationConfig, IntegrationType } from './integrationTypes';
78

@@ -22,7 +23,13 @@ export class IntegrationStorage {
2223

2324
public readonly onDidChangeIntegrations = this._onDidChangeIntegrations.event;
2425

25-
constructor(@inject(IEncryptedStorage) private readonly encryptedStorage: IEncryptedStorage) {}
26+
constructor(
27+
@inject(IEncryptedStorage) private readonly encryptedStorage: IEncryptedStorage,
28+
@inject(IAsyncDisposableRegistry) asyncRegistry: IAsyncDisposableRegistry
29+
) {
30+
// Register for disposal when the extension deactivates
31+
asyncRegistry.push(this);
32+
}
2633

2734
/**
2835
* Get all stored integration configurations
@@ -168,4 +175,11 @@ export class IntegrationStorage {
168175
const indexJson = JSON.stringify(integrationIds);
169176
await this.encryptedStorage.store(INTEGRATION_SERVICE_NAME, 'index', indexJson);
170177
}
178+
179+
/**
180+
* Dispose of resources to prevent memory leaks
181+
*/
182+
public dispose(): void {
183+
this._onDidChangeIntegrations.dispose();
184+
}
171185
}

src/notebooks/deepnote/integrations/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Event } from 'vscode';
2+
import { IDisposable } from '../../../platform/common/types';
23
import { IntegrationConfig, IntegrationWithStatus } from './integrationTypes';
34

45
export const IIntegrationStorage = Symbol('IIntegrationStorage');
5-
export interface IIntegrationStorage {
6+
export interface IIntegrationStorage extends IDisposable {
67
/**
78
* Event fired when integrations change
89
*/

0 commit comments

Comments
 (0)