瀏覽代碼

Adds storage prefix constant

main
Eric Amodio 1 年之前
父節點
當前提交
1d8358f181
共有 2 個文件被更改,包括 8 次插入6 次删除
  1. +1
    -0
      src/constants.ts
  2. +7
    -6
      src/storage.ts

+ 1
- 0
src/constants.ts 查看文件

@ -1,5 +1,6 @@
export const commandPrefix = 'gitlens';
export const configPrefix = 'gitlens';
export const storagePrefix = 'gitlens';
export const quickPickTitleMaxChars = 80;
export const ImageMimetypes: Record<string, string> = {

+ 7
- 6
src/storage.ts 查看文件

@ -1,6 +1,7 @@
import type { Disposable, Event, ExtensionContext, SecretStorageChangeEvent } from 'vscode';
import { EventEmitter } from 'vscode';
import type { ViewShowBranchComparison } from './config';
import { storagePrefix } from './constants';
import type { Environment } from './container';
import type { StoredSearchQuery } from './git/search';
import type { Subscription } from './subscription';
@ -50,18 +51,18 @@ export class Storage implements Disposable {
get<T extends keyof GlobalStorage>(key: T, defaultValue: GlobalStorage[T]): GlobalStorage[T];
@debug({ logThreshold: 50 })
get(key: keyof (GlobalStorage & DeprecatedGlobalStorage), defaultValue?: unknown): unknown | undefined {
return this.context.globalState.get(`gitlens:${key}`, defaultValue);
return this.context.globalState.get(`${storagePrefix}:${key}`, defaultValue);
}
@debug({ logThreshold: 250 })
async delete(key: keyof (GlobalStorage & DeprecatedGlobalStorage)): Promise<void> {
await this.context.globalState.update(`gitlens:${key}`, undefined);
await this.context.globalState.update(`${storagePrefix}:${key}`, undefined);
this._onDidChange.fire({ key: key, workspace: false });
}
@debug({ args: { 1: false }, logThreshold: 250 })
async store<T extends keyof GlobalStorage>(key: T, value: GlobalStorage[T] | undefined): Promise<void> {
await this.context.globalState.update(`gitlens:${key}`, value);
await this.context.globalState.update(`${storagePrefix}:${key}`, value);
this._onDidChange.fire({ key: key, workspace: false });
}
@ -89,18 +90,18 @@ export class Storage implements Disposable {
key: keyof (WorkspaceStorage & DeprecatedWorkspaceStorage),
defaultValue?: unknown,
): unknown | undefined {
return this.context.workspaceState.get(`gitlens:${key}`, defaultValue);
return this.context.workspaceState.get(`${storagePrefix}:${key}`, defaultValue);
}
@debug({ logThreshold: 250 })
async deleteWorkspace(key: keyof (WorkspaceStorage & DeprecatedWorkspaceStorage)): Promise<void> {
await this.context.workspaceState.update(`gitlens:${key}`, undefined);
await this.context.workspaceState.update(`${storagePrefix}:${key}`, undefined);
this._onDidChange.fire({ key: key, workspace: true });
}
@debug({ args: { 1: false }, logThreshold: 250 })
async storeWorkspace(key: keyof WorkspaceStorage, value: unknown | undefined): Promise<void> {
await this.context.workspaceState.update(`gitlens:${key}`, value);
await this.context.workspaceState.update(`${storagePrefix}:${key}`, value);
this._onDidChange.fire({ key: key, workspace: true });
}
}

Loading…
取消
儲存