Ver código fonte

Adds storage prefix constant

main
Eric Amodio 1 ano atrás
pai
commit
1d8358f181
2 arquivos alterados com 8 adições e 6 exclusões
  1. +1
    -0
      src/constants.ts
  2. +7
    -6
      src/storage.ts

+ 1
- 0
src/constants.ts Ver arquivo

@ -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 Ver arquivo

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

Carregando…
Cancelar
Salvar