Skip to content

Commit 6d2fcc8

Browse files
Option for disabling release notes (#29)
Co-authored-by: Jean Pierre <[email protected]>
1 parent 00d1eab commit 6d2fcc8

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@
5959
"default": "https://gitpod.io/",
6060
"scope": "application"
6161
},
62+
"gitpod.showReleaseNotes": {
63+
"type": "boolean",
64+
"description": "Show the Gitpod Changelog whenever a new one comes out.",
65+
"default": true,
66+
"scope": "application"
67+
},
6268
"gitpod.remote.useLocalApp": {
6369
"type": "boolean",
6470
"description": "Use the local companion app to connect to a remote workspace.\nWarning: Connecting to a remote workspace using local companion app will be removed in the near future.",

src/common/cache.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ export class CacheHelper {
4040
return now > data.expiration ? undefined : data.value;
4141
}
4242

43-
async getOrRefresh<T>(key: string, refreshCallback: () => Thenable<{ value: T; ttl?: number }>): Promise<T> {
43+
async getOrRefresh<T>(key: string, refreshCallback: () => Thenable<{ value: T; ttl?: number }>): Promise<T | undefined> {
4444
let value = this.get<T>(key);
4545
if (value === undefined) {
46-
const result = await refreshCallback();
47-
await this.set(key, result.value, result.ttl);
48-
value = result.value;
46+
try {
47+
const result = await refreshCallback();
48+
await this.set(key, result.value, result.ttl);
49+
value = result.value;
50+
} catch {
51+
}
4952
}
5053
return value;
5154
}

src/extension.ts

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

82-
context.subscriptions.push(new ReleaseNotes(context));
82+
if (vscode.workspace.getConfiguration('gitpod').get<boolean>('enableReleaseNotes')) {
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+
}
8389

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

src/releaseNotes.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ export class ReleaseNotes extends Disposable {
7070
ttl: this.getResponseCacheTime(resp),
7171
};
7272
});
73+
if (!md) {
74+
return;
75+
}
7376

7477
const parseInfo = (md: string) => {
7578
if (!md.startsWith('---')) {
@@ -112,7 +115,15 @@ export class ReleaseNotes extends Disposable {
112115
}
113116

114117
const releaseId = await this.getLastPublish();
118+
if (!releaseId) {
119+
return;
120+
}
121+
115122
const mdContent = await this.loadChangelog(releaseId);
123+
if (!mdContent) {
124+
return;
125+
}
126+
116127
const html = await vscode.commands.executeCommand<string>('markdown.api.render', mdContent);
117128
this.panel.webview.html = `<!DOCTYPE html>
118129
<html lang="en">
@@ -142,10 +153,13 @@ export class ReleaseNotes extends Disposable {
142153
}
143154

144155
private async showIfNewRelease(lastReadId: string | undefined) {
145-
const releaseId = await this.getLastPublish();
146-
console.log(`gitpod release notes lastReadId: ${lastReadId}, latestReleaseId: ${releaseId}`);
147-
if (releaseId !== lastReadId) {
148-
this.createOrShow();
156+
const showReleaseNotes = vscode.workspace.getConfiguration('gitpod').get<boolean>('showReleaseNotes');
157+
if (showReleaseNotes) {
158+
const releaseId = await this.getLastPublish();
159+
if (releaseId && releaseId !== lastReadId) {
160+
console.log(`gitpod release notes lastReadId: ${lastReadId}, latestReleaseId: ${releaseId}`);
161+
this.createOrShow();
162+
}
149163
}
150164
}
151165

0 commit comments

Comments
 (0)