Skip to content

Commit 18c9e00

Browse files
committed
Refactor Release notes init
Add some logging and make sure even if release notes are disabled via config, you can manually show them via the command palette.
1 parent 866ba5d commit 18c9e00

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/extension.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,7 @@ export async function activate(context: vscode.ExtensionContext) {
7979
}
8080
}));
8181

82-
if (vscode.workspace.getConfiguration('gitpod').get<boolean>('showReleaseNotes')) {
83-
const lastRead = context.globalState.get<string>(ReleaseNotes.RELEASE_NOTES_LAST_READ_KEY);
84-
logger.info(`Last read release notes: ${lastRead}`);
85-
context.subscriptions.push(new ReleaseNotes(context));
86-
} else {
87-
logger.info('Release notes are disabled');
88-
}
82+
context.subscriptions.push(new ReleaseNotes(context, logger));
8983

9084
if (!context.globalState.get<boolean>(FIRST_INSTALL_KEY, false)) {
9185
await context.globalState.update(FIRST_INSTALL_KEY, true);

src/releaseNotes.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as vscode from 'vscode';
77
import { load } from 'js-yaml';
88
import { CacheHelper } from './common/cache';
99
import { Disposable, disposeAll } from './common/dispose';
10+
import Log from './common/logger';
1011

1112
export class ReleaseNotes extends Disposable {
1213
public static readonly viewType = 'gitpodReleaseNotes';
@@ -20,14 +21,20 @@ export class ReleaseNotes extends Disposable {
2021

2122
constructor(
2223
private readonly context: vscode.ExtensionContext,
24+
private readonly logger: Log,
2325
) {
2426
super();
2527

2628
this.lastReadId = this.context.globalState.get<string>(ReleaseNotes.RELEASE_NOTES_LAST_READ_KEY);
2729

2830
this._register(vscode.commands.registerCommand('gitpod.showReleaseNotes', () => this.createOrShow()));
2931

30-
this.showIfNewRelease(this.lastReadId);
32+
const releaseNotesEnabled = vscode.workspace.getConfiguration('gitpod').get<boolean>('showReleaseNotes');
33+
if (releaseNotesEnabled) {
34+
this.showIfNewRelease(this.lastReadId);
35+
} else {
36+
logger.info('Release notes are disabled');
37+
}
3138
}
3239

3340
private async getLastPublish() {
@@ -158,14 +165,12 @@ export class ReleaseNotes extends Disposable {
158165
}
159166

160167
private async showIfNewRelease(lastReadId: string | undefined) {
161-
const showReleaseNotes = vscode.workspace.getConfiguration('gitpod').get<boolean>('showReleaseNotes');
162-
if (showReleaseNotes) {
168+
this.logger.info(`Last read release notes: ${lastReadId}`);
163169
const releaseId = await this.getLastPublish();
164170
if (releaseId && releaseId !== lastReadId) {
165-
console.log(`gitpod release notes lastReadId: ${lastReadId}, latestReleaseId: ${releaseId}`);
171+
this.logger.info(`gitpod release notes lastReadId: ${lastReadId}, latestReleaseId: ${releaseId}`);
166172
this.createOrShow();
167173
}
168-
}
169174
}
170175

171176
public createOrShow() {

0 commit comments

Comments
 (0)