1 import * as vscode from 'vscode';
2 import { log } from './util';
4 export class PersistentState {
5 constructor(private readonly globalState: vscode.Memento) {
6 const { lastCheck, nightlyReleaseId, serverVersion } = this;
7 log.info("PersistentState:", { lastCheck, nightlyReleaseId, serverVersion });
11 * Used to check for *nightly* updates once an hour.
13 get lastCheck(): number | undefined {
14 return this.globalState.get("lastCheck");
16 async updateLastCheck(value: number) {
17 await this.globalState.update("lastCheck", value);
21 * Release id of the *nightly* extension.
22 * Used to check if we should update.
24 get nightlyReleaseId(): number | undefined {
25 return this.globalState.get("releaseId");
27 async updateNightlyReleaseId(value: number) {
28 await this.globalState.update("releaseId", value);
30 async removeNightlyReleaseId() {
31 await this.globalState.update("releaseId", undefined);
35 * Version of the extension that installed the server.
36 * Used to check if we need to update the server.
38 get serverVersion(): string | undefined {
39 return this.globalState.get("serverVersion");
41 async updateServerVersion(value: string | undefined) {
42 await this.globalState.update("serverVersion", value);
46 * Github authorization token.
47 * This is used for API requests against the Github API.
49 get githubToken(): string | undefined {
50 return this.globalState.get("githubToken");
52 async updateGithubToken(value: string | undefined) {
53 await this.globalState.update("githubToken", value);