mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
💄
This commit is contained in:
parent
145f022c19
commit
cdaf61edab
|
@ -72,7 +72,8 @@ export interface INeverShowAgainOptions {
|
|||
|
||||
/**
|
||||
* Whether to persist the choice in the current workspace or for all workspaces. By
|
||||
* default it will be persisted for all workspaces (= `NeverShowAgainScope.GLOBAL`).
|
||||
* default it will be persisted for all workspaces across all profiles
|
||||
* (= `NeverShowAgainScope.APPLICATION`).
|
||||
*/
|
||||
readonly scope?: NeverShowAgainScope;
|
||||
}
|
||||
|
|
|
@ -64,8 +64,11 @@ export class BrowserStorageService extends AbstractStorageService {
|
|||
const promises: Promise<IIndexedDBStorageDatabase>[] = [];
|
||||
promises.push(IndexedDBStorageDatabase.create({ id: this.getId(StorageScope.APPLICATION), broadcastChanges: true }, this.logService));
|
||||
promises.push(IndexedDBStorageDatabase.create({ id: this.getId(StorageScope.WORKSPACE) }, this.logService));
|
||||
// Create global storage only if the current profile is not a default profie otherwise we use the application storage
|
||||
if (!this.userDataProfileService.currentProfile.isDefault) {
|
||||
|
||||
// Create global storage only if the current profile is not a
|
||||
// default profie otherwise we use the application storage
|
||||
|
||||
promises.push(IndexedDBStorageDatabase.create({ id: this.getId(StorageScope.GLOBAL), broadcastChanges: true }, this.logService));
|
||||
}
|
||||
const [applicationStorageDatabase, workspaceStorageDatabase, globalStorageDatabase] = await Promises.settled(promises);
|
||||
|
|
|
@ -31,7 +31,7 @@ export enum WillSaveStateReason {
|
|||
}
|
||||
|
||||
export interface IWillSaveStateEvent {
|
||||
reason: WillSaveStateReason;
|
||||
readonly reason: WillSaveStateReason;
|
||||
}
|
||||
|
||||
export interface IStorageService {
|
||||
|
@ -522,12 +522,15 @@ export abstract class AbstractStorageService extends Disposable implements IStor
|
|||
}
|
||||
|
||||
async logStorage(): Promise<void> {
|
||||
const applicationItems = this.getStorage(StorageScope.APPLICATION)?.items ?? new Map<string, string>();
|
||||
const globalItems = this.getStorage(StorageScope.GLOBAL)?.items ?? new Map<string, string>();
|
||||
const workspaceItems = this.getStorage(StorageScope.WORKSPACE)?.items ?? new Map<string, string>();
|
||||
|
||||
return logStorage(
|
||||
applicationItems,
|
||||
globalItems,
|
||||
workspaceItems,
|
||||
this.getLogDetails(StorageScope.APPLICATION) ?? '',
|
||||
this.getLogDetails(StorageScope.GLOBAL) ?? '',
|
||||
this.getLogDetails(StorageScope.WORKSPACE) ?? ''
|
||||
);
|
||||
|
@ -553,9 +556,9 @@ export class InMemoryStorageService extends AbstractStorageService {
|
|||
constructor() {
|
||||
super();
|
||||
|
||||
this._register(this.applicationStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.APPLICATION, key)));
|
||||
this._register(this.globalStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.GLOBAL, key)));
|
||||
this._register(this.workspaceStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.WORKSPACE, key)));
|
||||
this._register(this.globalStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.GLOBAL, key)));
|
||||
this._register(this.applicationStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.APPLICATION, key)));
|
||||
}
|
||||
|
||||
protected getStorage(scope: StorageScope): IStorage {
|
||||
|
@ -587,7 +590,7 @@ export class InMemoryStorageService extends AbstractStorageService {
|
|||
}
|
||||
}
|
||||
|
||||
export async function logStorage(global: Map<string, string>, workspace: Map<string, string>, globalPath: string, workspacePath: string): Promise<void> {
|
||||
export async function logStorage(application: Map<string, string>, global: Map<string, string>, workspace: Map<string, string>, applicationPath: string, globalPath: string, workspacePath: string): Promise<void> {
|
||||
const safeParse = (value: string) => {
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
|
@ -596,6 +599,13 @@ export async function logStorage(global: Map<string, string>, workspace: Map<str
|
|||
}
|
||||
};
|
||||
|
||||
const applicationItems = new Map<string, string>();
|
||||
const applicationItemsParsed = new Map<string, string>();
|
||||
application.forEach((value, key) => {
|
||||
applicationItems.set(key, value);
|
||||
applicationItemsParsed.set(key, safeParse(value));
|
||||
});
|
||||
|
||||
const globalItems = new Map<string, string>();
|
||||
const globalItemsParsed = new Map<string, string>();
|
||||
global.forEach((value, key) => {
|
||||
|
@ -610,15 +620,31 @@ export async function logStorage(global: Map<string, string>, workspace: Map<str
|
|||
workspaceItemsParsed.set(key, safeParse(value));
|
||||
});
|
||||
|
||||
console.group(`Storage: Global (path: ${globalPath})`);
|
||||
const globalValues: { key: string; value: string }[] = [];
|
||||
globalItems.forEach((value, key) => {
|
||||
globalValues.push({ key, value });
|
||||
if (applicationPath !== globalPath) {
|
||||
console.group(`Storage: Application (path: ${applicationPath})`);
|
||||
} else {
|
||||
console.group(`Storage: Application & Global (path: ${applicationPath}, default profile)`);
|
||||
}
|
||||
const applicationValues: { key: string; value: string }[] = [];
|
||||
applicationItems.forEach((value, key) => {
|
||||
applicationValues.push({ key, value });
|
||||
});
|
||||
console.table(globalValues);
|
||||
console.table(applicationValues);
|
||||
console.groupEnd();
|
||||
|
||||
console.log(globalItemsParsed);
|
||||
console.log(applicationItemsParsed);
|
||||
|
||||
if (applicationPath !== globalPath) {
|
||||
console.group(`Storage: Global (path: ${globalPath}, profile specific)`);
|
||||
const globalValues: { key: string; value: string }[] = [];
|
||||
globalItems.forEach((value, key) => {
|
||||
globalValues.push({ key, value });
|
||||
});
|
||||
console.table(globalValues);
|
||||
console.groupEnd();
|
||||
|
||||
console.log(globalItemsParsed);
|
||||
}
|
||||
|
||||
console.group(`Storage: Workspace (path: ${workspacePath})`);
|
||||
const workspaceValues: { key: string; value: string }[] = [];
|
||||
|
|
|
@ -24,8 +24,8 @@ export interface IBaseSerializableStorageRequest {
|
|||
readonly profile: IUserDataProfileDto | undefined;
|
||||
|
||||
/**
|
||||
* Workspace to correlate storage. Can be undefined to denote
|
||||
* application or global scope depending on profile.
|
||||
* Workspace to correlate storage. Can be undefined to
|
||||
* denote application or global scope depending on profile.
|
||||
*/
|
||||
readonly workspace: ISerializedWorkspaceIdentifier | ISerializedSingleFolderWorkspaceIdentifier | IEmptyWorkspaceIdentifier | undefined;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import { ApplicationStorageMain, GlobalStorageMain, InMemoryStorageMain, IStorag
|
|||
import { IUserDataProfile, IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
|
||||
import { IAnyWorkspaceIdentifier, IEmptyWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
|
||||
|
||||
//#region Storage Main Service (intent: make global and workspace storage accessible to windows from main process)
|
||||
//#region Storage Main Service (intent: make application, global and workspace storage accessible to windows from main process)
|
||||
|
||||
export const IStorageMainService = createDecorator<IStorageMainService>('storageMainService');
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
|
|||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { asJson, IRequestService } from 'vs/platform/request/common/request';
|
||||
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
|
||||
import { ITelemetryService, lastSessionDateStorageKey } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkspaceTagsService } from 'vs/workbench/contrib/tags/common/workspaceTags';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
|
@ -483,7 +483,7 @@ export class ExperimentService extends Disposable implements IExperimentService
|
|||
return Promise.resolve(ExperimentState.NoRun);
|
||||
}
|
||||
|
||||
const isNewUser = !this.storageService.get(lastSessionDateStorageKey, StorageScope.APPLICATION);
|
||||
const isNewUser = this.storageService.isNew(StorageScope.APPLICATION);
|
||||
if ((condition.newUser === true && !isNewUser)
|
||||
|| (condition.newUser === false && isNewUser)) {
|
||||
return Promise.resolve(ExperimentState.NoRun);
|
||||
|
|
|
@ -151,7 +151,7 @@ export class NotificationService extends Disposable implements INotificationServ
|
|||
case NeverShowAgainScope.WORKSPACE:
|
||||
return StorageScope.WORKSPACE;
|
||||
default:
|
||||
return StorageScope.GLOBAL;
|
||||
return StorageScope.APPLICATION;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue