]> git.lizzy.rs Git - rust.git/blob - editors/code/src/persistent_state.ts
Improve client logging (use output channel and more log levels)
[rust.git] / editors / code / src / persistent_state.ts
1 import * as vscode from 'vscode';
2 import { log } from './util';
3
4 export class PersistentState {
5     constructor(private readonly globalState: vscode.Memento) {
6         const { lastCheck, releaseId, serverVersion } = this;
7         log.info("PersistentState:", { lastCheck, releaseId, serverVersion });
8     }
9
10     /**
11      * Used to check for *nightly* updates once an hour.
12      */
13     get lastCheck(): number | undefined {
14         return this.globalState.get("lastCheck");
15     }
16     async updateLastCheck(value: number) {
17         await this.globalState.update("lastCheck", value);
18     }
19
20     /**
21      * Release id of the *nightly* extension.
22      * Used to check if we should update.
23      */
24     get releaseId(): number | undefined {
25         return this.globalState.get("releaseId");
26     }
27     async updateReleaseId(value: number) {
28         await this.globalState.update("releaseId", value);
29     }
30
31     /**
32      * Version of the extension that installed the server.
33      * Used to check if we need to update the server.
34      */
35     get serverVersion(): string | undefined {
36         return this.globalState.get("serverVersion");
37     }
38     async updateServerVersion(value: string | undefined) {
39         await this.globalState.update("serverVersion", value);
40     }
41 }