Skip to content

Commit

Permalink
Refactor BaseStorage and VsStorage constructors to accept globalState…
Browse files Browse the repository at this point in the history
… as a parameter

Signed-off-by: worksofliam <[email protected]>
  • Loading branch information
worksofliam committed Jan 21, 2025
1 parent 3c0cefb commit f65fdaa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
19 changes: 9 additions & 10 deletions src/api/configuration/storage/BaseStorage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export abstract class BaseStorage {
protected readonly globalState: any;

constructor() {
this.globalState = new Map<string, any>();
}
constructor(globalState: any) {
this.globalState = globalState;
}


keys(): readonly string[] {
return Array.from(this.globalState.keys());
Expand All @@ -22,10 +23,8 @@ export abstract class BaseStorage {
}
}

export class VirtualStorage extends BaseStorage {
protected readonly globalState: Map<string, any> = new Map<string, any>();

constructor() {
super();
}
}
export class VirtualStorage extends BaseStorage {
constructor() {
super(new Map<string, any>());
}
}
9 changes: 2 additions & 7 deletions src/config/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@ import * as vscode from 'vscode';
import { BaseStorage } from '../api/configuration/storage/BaseStorage';

export class VsStorage extends BaseStorage {
declare protected readonly globalState;
declare protected readonly globalState: vscode.Memento;
private connectionName: string = "";

constructor(context: vscode.ExtensionContext) {
super();
super(context.globalState);
this.globalState = context.globalState;
}

setConnectionName(connectionName: string) {
this.connectionName = connectionName;
}

public keys(): readonly string[] {
return this.globalState.keys();
}
Expand Down

0 comments on commit f65fdaa

Please sign in to comment.