Skip to content

Add in product changelog #7

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
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: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"onCommand:gitpod.syncProvider.remove",
"onCommand:gitpod.exportLogs",
"onCommand:gitpod.api.autoTunnel",
"onCommand:gitpod.showReleaseNotes",
"onAuthenticationRequest:gitpod",
"onUri"
],
Expand Down Expand Up @@ -92,6 +93,11 @@
"command": "gitpod.exportLogs",
"category": "Gitpod",
"title": "Export all logs"
},
{
"command": "gitpod.showReleaseNotes",
"category": "Gitpod",
"title": "Show Release Notes"
}
]
},
Expand All @@ -109,6 +115,7 @@
"@types/analytics-node": "^3.1.9",
"@types/crypto-js": "4.1.1",
"@types/google-protobuf": "^3.7.4",
"@types/js-yaml": "^4.0.5",
"@types/node": "16.x",
"@types/node-fetch": "^2.5.12",
"@types/semver": "^7.3.10",
Expand All @@ -135,6 +142,7 @@
"@gitpod/local-app-api-grpcweb": "main",
"@improbable-eng/grpc-web-node-http-transport": "^0.14.0",
"analytics-node": "^6.0.0",
"js-yaml": "^4.1.0",
"node-fetch": "2.6.7",
"pkce-challenge": "^3.0.0",
"semver": "^7.3.7",
Expand Down
52 changes: 52 additions & 0 deletions src/common/cache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Gitpod. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';

const CACHE_KEY = 'gitpod.cache';

interface CacheObject {
value: any;
expiration?: number;
}

interface CacheMap { [key: string]: CacheObject }

export class CacheHelper {
constructor(private readonly context: vscode.ExtensionContext) { }

set(key: string, value: any, expiration?: number) {
let obj = this.context.globalState.get<CacheMap>(CACHE_KEY);
if (!obj) {
obj = {};
}
const exp = expiration ? ((+ new Date()) / 1000 + expiration) : undefined;
obj[key] = { value, expiration: exp };
return this.context.globalState.update(CACHE_KEY, obj);
}

get(key: string) {
const value = this.context.globalState.get<CacheMap>(CACHE_KEY);
if (!value || !value[key]) {
return undefined;
}
const data = value[key];
if (!data.expiration) {
return data.value;
}
const now = (+ new Date()) / 1000;
return now > data.expiration ? undefined : data.value;
}

async handy<T>(key: string, cb: () => Thenable<{ value: T; ttl?: number }>) {
let d = this.get(key);
if (d === undefined) {
const tmp = await cb();
await this.set(key, tmp.value, tmp.ttl);
d = tmp.value;
}
return d as T;
}
}
3 changes: 3 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { enableSettingsSync, updateSyncContext } from './settingsSync';
import { GitpodServer } from './gitpodServer';
import TelemetryReporter from './telemetryReporter';
import { exportLogs } from './exportLogs';
import { registerReleaseNotesView } from './releaseNotes';

const EXTENSION_ID = 'gitpod.gitpod-desktop';
const FIRST_INSTALL_KEY = 'gitpod-desktop.firstInstall';
Expand Down Expand Up @@ -89,6 +90,8 @@ export async function activate(context: vscode.ExtensionContext) {
await context.globalState.update(FIRST_INSTALL_KEY, true);
telemetry.sendTelemetryEvent('gitpod_desktop_installation', { kind: 'install' });
}

registerReleaseNotesView(context);
}

export async function deactivate() {
Expand Down
Loading