Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Sync version key #24

Merged
merged 1 commit into from
Jan 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class WhatsNewManager {
private sponsorProvider: SponsorProvider | undefined;

private extension!: vscode.Extension<any>;
private versionKey!: string;

constructor(context: vscode.ExtensionContext) {
this.context = context;
Expand All @@ -28,6 +29,9 @@ export class WhatsNewManager {
this.publisher = publisher;
this.extensionName = extensionName
this.contentProvider = contentProvider;
this.versionKey = `${this.extensionName}.version`;

this.context.globalState.setKeysForSync([this.versionKey]);

return this;
}
Expand All @@ -47,7 +51,7 @@ export class WhatsNewManager {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.extension = vscode.extensions.getExtension(`${this.publisher}.${this.extensionName}`)!;

const previousExtensionVersion = this.context.globalState.get<string>(`${this.extensionName}.version`);
const previousExtensionVersion = this.context.globalState.get<string>(this.versionKey);

this.showPageIfVersionDiffers(this.extension.packageJSON.version, previousExtensionVersion);
}
Expand Down Expand Up @@ -88,7 +92,7 @@ export class WhatsNewManager {
}

// "major", "minor"
this.context.globalState.update(`${this.extensionName}.version`, currentVersion);
this.context.globalState.update(this.versionKey, currentVersion);
this.showPage();
}

Expand Down