@@ -744,10 +744,10 @@ index 096b9e23493539c9937940a56e555d95bbae38d9..ef37e614004f550f7b64eacd362f6894
744
744
remove(key: string, scope: StorageScope): void {
745
745
diff --git a/src/vs/server/browser/client.ts b/src/vs/server/browser/client.ts
746
746
new file mode 100644
747
- index 0000000000000000000000000000000000000000..3c0703b7174ad792a4b42841e96ee93765d71601
747
+ index 0000000000000000000000000000000000000000..667ca961830feaf6fc5e5bb7ef2df3b8be97b176
748
748
--- /dev/null
749
749
+++ b/src/vs/server/browser/client.ts
750
- @@ -0,0 +1,189 @@
750
+ @@ -0,0 +1,237 @@
751
751
+ import { Emitter } from 'vs/base/common/event';
752
752
+ import { URI } from 'vs/base/common/uri';
753
753
+ import { localize } from 'vs/nls';
@@ -766,6 +766,7 @@ index 0000000000000000000000000000000000000000..3c0703b7174ad792a4b42841e96ee937
766
766
+ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
767
767
+ import { Options } from 'vs/server/ipc.d';
768
768
+ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
769
+ + import { ILogService } from 'vs/platform/log/common/log';
769
770
+
770
771
+ class TelemetryService extends TelemetryChannelClient {
771
772
+ public constructor(
@@ -897,8 +898,55 @@ index 0000000000000000000000000000000000000000..3c0703b7174ad792a4b42841e96ee937
897
898
+ });
898
899
+ }
899
900
+
901
+ + const logService = (services.get(ILogService) as ILogService);
902
+ + const storageService = (services.get(IStorageService) as IStorageService)
903
+ + const getUpdate = async (): Promise<void> => {
904
+ + logService.debug("Checking for update...");
905
+ +
906
+ + const response = await fetch("update/check", {
907
+ + headers: { "Accept": "application/json" },
908
+ + });
909
+ + if (!response.ok) {
910
+ + throw new Error(response.statusText);
911
+ + }
912
+ + const json = await response.json();
913
+ + if (json.error) {
914
+ + throw new Error(json.error);
915
+ + }
916
+ + if (json.isLatest) {
917
+ + return;
918
+ + }
919
+ +
920
+ + const lastNoti = storageService.getNumber("csLastUpdateNotification", StorageScope.GLOBAL);
921
+ + if (lastNoti) {
922
+ + // Only remind them again after two days.
923
+ + const timeout = 1000*60*24*2
924
+ + const threshold = lastNoti + timeout;
925
+ + if (Date.now() < threshold) {
926
+ + return;
927
+ + }
928
+ + }
929
+ +
930
+ + storageService.store("csLastUpdateNotification", Date.now(), StorageScope.GLOBAL);
931
+ + (services.get(INotificationService) as INotificationService).notify({
932
+ + severity: Severity.Info,
933
+ + message: `[code-server v${json.latest}](https://github.com/cdr/code-server/releases/tag/v${json.latest}) has been released!`,
934
+ + });
935
+ + };
936
+ +
937
+ + const updateLoop = (): void => {
938
+ + getUpdate().catch((error) => {
939
+ + logService.debug(`failed to check for update: ${error}`);
940
+ + }).finally(() => {
941
+ + // Check again every 6 hours.
942
+ + setTimeout(updateLoop, 1000*60*6);
943
+ + });
944
+ + };
945
+ +
946
+ + updateLoop();
947
+ +
900
948
+ // This will be used to set the background color while VS Code loads.
901
- + const theme = (services.get(IStorageService) as IStorageService) .get("colorThemeData", StorageScope.GLOBAL);
949
+ + const theme = storageService .get("colorThemeData", StorageScope.GLOBAL);
902
950
+ if (theme) {
903
951
+ localStorage.setItem("colorThemeData", theme);
904
952
+ }
0 commit comments