未验证 提交 5e2ae873 编写于 作者: E Erich Gamma 提交者: GitHub

Opt in syncing global state (#96662)

Fixes #93332
上级 0476956d
...@@ -10,6 +10,7 @@ import { IWorkbenchContributionsRegistry, IWorkbenchContribution, Extensions as ...@@ -10,6 +10,7 @@ import { IWorkbenchContributionsRegistry, IWorkbenchContribution, Extensions as
import { Registry } from 'vs/platform/registry/common/platform'; import { Registry } from 'vs/platform/registry/common/platform';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
import { ISurveyData, IProductService } from 'vs/platform/product/common/productService'; import { ISurveyData, IProductService } from 'vs/platform/product/common/productService';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { Severity, INotificationService } from 'vs/platform/notification/common/notification'; import { Severity, INotificationService } from 'vs/platform/notification/common/notification';
...@@ -25,6 +26,7 @@ class LanguageSurvey extends Disposable { ...@@ -25,6 +26,7 @@ class LanguageSurvey extends Disposable {
constructor( constructor(
data: ISurveyData, data: ISurveyData,
storageService: IStorageService, storageService: IStorageService,
storageKeysSyncRegistryService: IStorageKeysSyncRegistryService,
notificationService: INotificationService, notificationService: INotificationService,
telemetryService: ITelemetryService, telemetryService: ITelemetryService,
modelService: IModelService, modelService: IModelService,
...@@ -41,6 +43,14 @@ class LanguageSurvey extends Disposable { ...@@ -41,6 +43,14 @@ class LanguageSurvey extends Disposable {
const EDITED_LANGUAGE_COUNT_KEY = `${data.surveyId}.editedCount`; const EDITED_LANGUAGE_COUNT_KEY = `${data.surveyId}.editedCount`;
const EDITED_LANGUAGE_DATE_KEY = `${data.surveyId}.editedDate`; const EDITED_LANGUAGE_DATE_KEY = `${data.surveyId}.editedDate`;
// opt-in to syncing
storageKeysSyncRegistryService.registerStorageKey({ key: SESSION_COUNT_KEY, version: 1 });
storageKeysSyncRegistryService.registerStorageKey({ key: LAST_SESSION_DATE_KEY, version: 1 });
storageKeysSyncRegistryService.registerStorageKey({ key: SKIP_VERSION_KEY, version: 1 });
storageKeysSyncRegistryService.registerStorageKey({ key: IS_CANDIDATE_KEY, version: 1 });
storageKeysSyncRegistryService.registerStorageKey({ key: EDITED_LANGUAGE_COUNT_KEY, version: 1 });
storageKeysSyncRegistryService.registerStorageKey({ key: EDITED_LANGUAGE_DATE_KEY, version: 1 });
const skipVersion = storageService.get(SKIP_VERSION_KEY, StorageScope.GLOBAL, ''); const skipVersion = storageService.get(SKIP_VERSION_KEY, StorageScope.GLOBAL, '');
if (skipVersion) { if (skipVersion) {
return; return;
...@@ -131,6 +141,7 @@ class LanguageSurveysContribution implements IWorkbenchContribution { ...@@ -131,6 +141,7 @@ class LanguageSurveysContribution implements IWorkbenchContribution {
constructor( constructor(
@IStorageService storageService: IStorageService, @IStorageService storageService: IStorageService,
@IStorageKeysSyncRegistryService storageKeysSyncRegistryService: IStorageKeysSyncRegistryService,
@INotificationService notificationService: INotificationService, @INotificationService notificationService: INotificationService,
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
@IModelService modelService: IModelService, @IModelService modelService: IModelService,
...@@ -144,7 +155,7 @@ class LanguageSurveysContribution implements IWorkbenchContribution { ...@@ -144,7 +155,7 @@ class LanguageSurveysContribution implements IWorkbenchContribution {
productService.surveys productService.surveys
.filter(surveyData => surveyData.surveyId && surveyData.editCount && surveyData.languageId && surveyData.surveyUrl && surveyData.userProbability) .filter(surveyData => surveyData.surveyId && surveyData.editCount && surveyData.languageId && surveyData.surveyUrl && surveyData.userProbability)
.map(surveyData => new LanguageSurvey(surveyData, storageService, notificationService, telemetryService, modelService, textFileService, openerService, productService)); .map(surveyData => new LanguageSurvey(surveyData, storageService, storageKeysSyncRegistryService, notificationService, telemetryService, modelService, textFileService, openerService, productService));
} }
} }
......
...@@ -9,6 +9,7 @@ import { IWorkbenchContributionsRegistry, IWorkbenchContribution, Extensions as ...@@ -9,6 +9,7 @@ import { IWorkbenchContributionsRegistry, IWorkbenchContribution, Extensions as
import { Registry } from 'vs/platform/registry/common/platform'; import { Registry } from 'vs/platform/registry/common/platform';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
import { IProductService } from 'vs/platform/product/common/productService'; import { IProductService } from 'vs/platform/product/common/productService';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { Severity, INotificationService } from 'vs/platform/notification/common/notification'; import { Severity, INotificationService } from 'vs/platform/notification/common/notification';
...@@ -26,6 +27,7 @@ class NPSContribution implements IWorkbenchContribution { ...@@ -26,6 +27,7 @@ class NPSContribution implements IWorkbenchContribution {
constructor( constructor(
@IStorageService storageService: IStorageService, @IStorageService storageService: IStorageService,
@IStorageKeysSyncRegistryService storageKeysSyncRegistryService: IStorageKeysSyncRegistryService,
@INotificationService notificationService: INotificationService, @INotificationService notificationService: INotificationService,
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
@IOpenerService openerService: IOpenerService, @IOpenerService openerService: IOpenerService,
...@@ -35,6 +37,12 @@ class NPSContribution implements IWorkbenchContribution { ...@@ -35,6 +37,12 @@ class NPSContribution implements IWorkbenchContribution {
return; return;
} }
// opt-in to syncing
storageKeysSyncRegistryService.registerStorageKey({ key: SESSION_COUNT_KEY, version: 1 });
storageKeysSyncRegistryService.registerStorageKey({ key: LAST_SESSION_DATE_KEY, version: 1 });
storageKeysSyncRegistryService.registerStorageKey({ key: SKIP_VERSION_KEY, version: 1 });
storageKeysSyncRegistryService.registerStorageKey({ key: IS_CANDIDATE_KEY, version: 1 });
const skipVersion = storageService.get(SKIP_VERSION_KEY, StorageScope.GLOBAL, ''); const skipVersion = storageService.get(SKIP_VERSION_KEY, StorageScope.GLOBAL, '');
if (skipVersion) { if (skipVersion) {
return; return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册