From bd9d240044a03032e328c34724299e5f3016a354 Mon Sep 17 00:00:00 2001 From: Alessandro Fragnani Date: Thu, 1 Jun 2023 18:56:10 -0300 Subject: [PATCH] Disable while installing lower version (Closes #42) --- src/Manager.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Manager.ts b/src/Manager.ts index 70b5e5e..5ee7bc1 100644 --- a/src/Manager.ts +++ b/src/Manager.ts @@ -61,7 +61,7 @@ export class WhatsNewManager { const previousExtensionVersion = this.context.globalState.get(this.versionKey); - await this.showPageIfVersionDiffers(this.extension.packageJSON.version, previousExtensionVersion); + await this.showPageIfCurrentVersionIsGreaterThanPrevisouVersion(this.extension.packageJSON.version, previousExtensionVersion); } public async showPage() { @@ -104,6 +104,28 @@ export class WhatsNewManager { await this.showPage(); } + public async showPageIfCurrentVersionIsGreaterThanPrevisouVersion(currentVersion: string, previousVersion: string | undefined) { + if (previousVersion) { + const differs: semver.ReleaseType | null = semver.diff(currentVersion, previousVersion); + const isGreaterThanPreviousVersion = semver.gt(currentVersion, previousVersion); + + // only "patch" should be suppressed + if (!differs || differs === "patch" || !isGreaterThanPreviousVersion) { + return; + } + } + + // "major", "minor" + this.context.globalState.update(this.versionKey, currentVersion); + + // + if (this.isRunningOnCodespaces() || this.isRunningOnGitpod()) { + return; + } + + await this.showPage(); + } + private async getWebviewContentLocal(webview: Webview, htmlFile: Uri, cssUrl: Uri, logoUrl: Uri): Promise { const pageBuilder = await WhatsNewPageBuilder.newBuilder(webview, htmlFile); let html = pageBuilder.updateExtensionPublisher(this.publisher)