2020-03-16 18:23:38 +00:00
|
|
|
import * as vscode from 'vscode';
|
2020-03-17 11:44:31 +00:00
|
|
|
import { log } from './util';
|
2020-03-16 18:23:38 +00:00
|
|
|
|
|
|
|
export class PersistentState {
|
2020-03-17 11:44:31 +00:00
|
|
|
constructor(private readonly globalState: vscode.Memento) {
|
|
|
|
const { lastCheck, releaseId, serverVersion } = this;
|
2020-07-05 14:42:52 +00:00
|
|
|
log.info("PersistentState:", { lastCheck, releaseId, serverVersion });
|
2020-03-16 18:23:38 +00:00
|
|
|
}
|
|
|
|
|
2020-03-17 11:44:31 +00:00
|
|
|
/**
|
|
|
|
* Used to check for *nightly* updates once an hour.
|
|
|
|
*/
|
|
|
|
get lastCheck(): number | undefined {
|
|
|
|
return this.globalState.get("lastCheck");
|
2020-03-16 18:23:38 +00:00
|
|
|
}
|
2020-03-17 11:44:31 +00:00
|
|
|
async updateLastCheck(value: number) {
|
|
|
|
await this.globalState.update("lastCheck", value);
|
2020-03-16 18:23:38 +00:00
|
|
|
}
|
|
|
|
|
2020-03-17 11:44:31 +00:00
|
|
|
/**
|
|
|
|
* Release id of the *nightly* extension.
|
|
|
|
* Used to check if we should update.
|
|
|
|
*/
|
|
|
|
get releaseId(): number | undefined {
|
|
|
|
return this.globalState.get("releaseId");
|
2020-03-16 18:23:38 +00:00
|
|
|
}
|
2020-03-17 11:44:31 +00:00
|
|
|
async updateReleaseId(value: number) {
|
|
|
|
await this.globalState.update("releaseId", value);
|
2020-03-16 18:23:38 +00:00
|
|
|
}
|
|
|
|
|
2020-03-17 11:44:31 +00:00
|
|
|
/**
|
|
|
|
* Version of the extension that installed the server.
|
|
|
|
* Used to check if we need to update the server.
|
|
|
|
*/
|
|
|
|
get serverVersion(): string | undefined {
|
|
|
|
return this.globalState.get("serverVersion");
|
|
|
|
}
|
|
|
|
async updateServerVersion(value: string | undefined) {
|
|
|
|
await this.globalState.update("serverVersion", value);
|
2020-03-16 18:23:38 +00:00
|
|
|
}
|
|
|
|
}
|