@@ -769,10 +769,10 @@ index 096b9e23493539c9937940a56e555d95bbae38d9..ef37e614004f550f7b64eacd362f6894
769
769
remove(key: string, scope: StorageScope): void {
770
770
diff --git a/src/vs/server/browser/client.ts b/src/vs/server/browser/client.ts
771
771
new file mode 100644
772
- index 0000000000000000000000000000000000000000..3c0703b7174ad792a4b42841e96ee93765d71601
772
+ index 0000000000000000000000000000000000000000..667ca961830feaf6fc5e5bb7ef2df3b8be97b176
773
773
--- /dev/null
774
774
+++ b/src/vs/server/browser/client.ts
775
- @@ -0,0 +1,189 @@
775
+ @@ -0,0 +1,237 @@
776
776
+ import { Emitter } from 'vs/base/common/event';
777
777
+ import { URI } from 'vs/base/common/uri';
778
778
+ import { localize } from 'vs/nls';
@@ -791,6 +791,7 @@ index 0000000000000000000000000000000000000000..3c0703b7174ad792a4b42841e96ee937
791
791
+ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
792
792
+ import { Options } from 'vs/server/ipc.d';
793
793
+ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
794
+ + import { ILogService } from 'vs/platform/log/common/log';
794
795
+
795
796
+ class TelemetryService extends TelemetryChannelClient {
796
797
+ public constructor(
@@ -922,8 +923,55 @@ index 0000000000000000000000000000000000000000..3c0703b7174ad792a4b42841e96ee937
922
923
+ });
923
924
+ }
924
925
+
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
+ +
925
973
+ // 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);
927
975
+ if (theme) {
928
976
+ localStorage.setItem("colorThemeData", theme);
929
977
+ }
0 commit comments