@@ -769,10 +769,10 @@ index 096b9e23493539c9937940a56e555d95bbae38d9..ef37e614004f550f7b64eacd362f6894
769769 remove(key: string, scope: StorageScope): void {
770770diff --git a/src/vs/server/browser/client.ts b/src/vs/server/browser/client.ts
771771new file mode 100644
772- index 0000000000000000000000000000000000000000..3c0703b7174ad792a4b42841e96ee93765d71601
772+ index 0000000000000000000000000000000000000000..667ca961830feaf6fc5e5bb7ef2df3b8be97b176
773773--- /dev/null
774774+++ b/src/vs/server/browser/client.ts
775- @@ -0,0 +1,189 @@
775+ @@ -0,0 +1,237 @@
776776+ import { Emitter } from 'vs/base/common/event';
777777+ import { URI } from 'vs/base/common/uri';
778778+ import { localize } from 'vs/nls';
@@ -791,6 +791,7 @@ index 0000000000000000000000000000000000000000..3c0703b7174ad792a4b42841e96ee937
791791+ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
792792+ import { Options } from 'vs/server/ipc.d';
793793+ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
794+ + import { ILogService } from 'vs/platform/log/common/log';
794795+
795796+ class TelemetryService extends TelemetryChannelClient {
796797+ public constructor(
@@ -922,8 +923,55 @@ index 0000000000000000000000000000000000000000..3c0703b7174ad792a4b42841e96ee937
922923+ });
923924+ }
924925+
926+ + const logService = (services.get(ILogService) as ILogService);
927+ + const storageService = (services.get(IStorageService) as IStorageService)
928+ + const getUpdate = async (): Promise<void> => {
929+ + logService.debug("Checking for update...");
930+ +
931+ + const response = await fetch("update/check", {
932+ + headers: { "Accept": "application/json" },
933+ + });
934+ + if (!response.ok) {
935+ + throw new Error(response.statusText);
936+ + }
937+ + const json = await response.json();
938+ + if (json.error) {
939+ + throw new Error(json.error);
940+ + }
941+ + if (json.isLatest) {
942+ + return;
943+ + }
944+ +
945+ + const lastNoti = storageService.getNumber("csLastUpdateNotification", StorageScope.GLOBAL);
946+ + if (lastNoti) {
947+ + // Only remind them again after two days.
948+ + const timeout = 1000*60*24*2
949+ + const threshold = lastNoti + timeout;
950+ + if (Date.now() < threshold) {
951+ + return;
952+ + }
953+ + }
954+ +
955+ + storageService.store("csLastUpdateNotification", Date.now(), StorageScope.GLOBAL);
956+ + (services.get(INotificationService) as INotificationService).notify({
957+ + severity: Severity.Info,
958+ + message: `[code-server v${json.latest}](https://github.com/cdr/code-server/releases/tag/v${json.latest}) has been released!`,
959+ + });
960+ + };
961+ +
962+ + const updateLoop = (): void => {
963+ + getUpdate().catch((error) => {
964+ + logService.debug(`failed to check for update: ${error}`);
965+ + }).finally(() => {
966+ + // Check again every 6 hours.
967+ + setTimeout(updateLoop, 1000*60*6);
968+ + });
969+ + };
970+ +
971+ + updateLoop();
972+ +
925973+ // This will be used to set the background color while VS Code loads.
926- + const theme = (services.get(IStorageService) as IStorageService) .get("colorThemeData", StorageScope.GLOBAL);
974+ + const theme = storageService .get("colorThemeData", StorageScope.GLOBAL);
927975+ if (theme) {
928976+ localStorage.setItem("colorThemeData", theme);
929977+ }
0 commit comments