Skip to content

Commit

Permalink
Merge pull request #43 from alefragnani/features/disable-while-instal…
Browse files Browse the repository at this point in the history
…ling-lower-version

Disable while installing lower version (Closes #42)
  • Loading branch information
alefragnani authored Jun 1, 2023
2 parents 19c1dfd + bd9d240 commit ca79bec
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class WhatsNewManager {

const previousExtensionVersion = this.context.globalState.get<string>(this.versionKey);

await this.showPageIfVersionDiffers(this.extension.packageJSON.version, previousExtensionVersion);
await this.showPageIfCurrentVersionIsGreaterThanPrevisouVersion(this.extension.packageJSON.version, previousExtensionVersion);
}

public async showPage() {
Expand Down Expand Up @@ -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<string> {
const pageBuilder = await WhatsNewPageBuilder.newBuilder(webview, htmlFile);
let html = pageBuilder.updateExtensionPublisher(this.publisher)
Expand Down

0 comments on commit ca79bec

Please sign in to comment.