Add storage support

Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
Sanjula Ganepola
2024-10-17 22:25:20 -04:00
parent b274529707
commit 9bd8a8af0c
3 changed files with 35 additions and 36 deletions

View File

@@ -1,5 +1,9 @@
import { ExtensionContext } from "vscode";
export enum StorageKey {
WorkspaceHistory = 'workspaceHistory'
}
export class StorageManager {
private context: ExtensionContext;
private storageKey: string = 'githubLocalActions';
@@ -12,11 +16,11 @@ export class StorageManager {
return this.context.globalState.keys();
}
get<T>(key: string): T | undefined {
get<T>(key: StorageKey): T | undefined {
return this.context.globalState.get<T>(`${this.storageKey}.${key}`);
}
async update(key: string, value: any): Promise<void> {
async update(key: StorageKey, value: any): Promise<void> {
await this.context.globalState.update(`${this.storageKey}.${key}`, value);
}
}