From ae662617a2bc49d025adaf9c4a8ff2dfa557d36c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 16 Mar 2020 19:23:38 +0100 Subject: Separate persistent mutable state from config That way, we clearly see which things are not change, and we also clearly see which things are persistent. --- editors/code/src/config.ts | 41 ----------------------------------------- 1 file changed, 41 deletions(-) (limited to 'editors/code/src/config.ts') diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index f63e1d20e..bd8096dd6 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -182,13 +182,6 @@ export class Config { return this.createGithubReleaseSource("rust-analyzer.vsix", NIGHTLY_TAG); } - readonly installedNightlyExtensionReleaseDate = new DateStorage( - "installed-nightly-extension-release-date", - this.ctx.globalState - ); - readonly serverReleaseDate = new DateStorage("server-release-date", this.ctx.globalState); - readonly serverReleaseTag = new Storage("server-release-tag", this.ctx.globalState, null); - // We don't do runtime config validation here for simplicity. More on stackoverflow: // https://stackoverflow.com/questions/60135780/what-is-the-best-way-to-type-check-the-configuration-for-vscode-extension @@ -232,37 +225,3 @@ export class Config { // for internal use get withSysroot() { return this.cfg.get("withSysroot", true) as boolean; } } - -export class Storage { - constructor( - private readonly key: string, - private readonly storage: vscode.Memento, - private readonly defaultVal: T - ) { } - - get(): T { - const val = this.storage.get(this.key, this.defaultVal); - log.debug(this.key, "==", val); - return val; - } - async set(val: T) { - log.debug(this.key, "=", val); - await this.storage.update(this.key, val); - } -} -export class DateStorage { - inner: Storage; - - constructor(key: string, storage: vscode.Memento) { - this.inner = new Storage(key, storage, null); - } - - get(): null | Date { - const dateStr = this.inner.get(); - return dateStr ? new Date(dateStr) : null; - } - - async set(date: null | Date) { - await this.inner.set(date ? date.toString() : null); - } -} -- cgit v1.2.3