Skip to content

Commit

Permalink
fix: replace DisposableStore with _store in storage change regist…
Browse files Browse the repository at this point in the history
…rations (#232224)
  • Loading branch information
bpasero authored Oct 25, 2024
1 parent 02094f5 commit b402ee3
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { Emitter, Event } from '../../../base/common/event.js';
import { Disposable, DisposableStore } from '../../../base/common/lifecycle.js';
import { Disposable } from '../../../base/common/lifecycle.js';
import { isUndefinedOrNull } from '../../../base/common/types.js';
import { DISABLED_EXTENSIONS_STORAGE_PATH, IExtensionIdentifier, IExtensionManagementService, IGlobalExtensionEnablementService, InstallOperation } from './extensionManagement.js';
import { areSameExtensions } from './extensionManagementUtil.js';
Expand Down Expand Up @@ -102,7 +102,7 @@ export class StorageManager extends Disposable {

constructor(private storageService: IStorageService) {
super();
this._register(storageService.onDidChangeValue(StorageScope.PROFILE, undefined, this._register(new DisposableStore()))(e => this.onDidStorageChange(e)));
this._register(storageService.onDidChangeValue(StorageScope.PROFILE, undefined, this._store)(e => this.onDidStorageChange(e)));
}

get(key: string, scope: StorageScope): IExtensionIdentifier[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { createDecorator } from '../../instantiation/common/instantiation.js';
import { Emitter, Event } from '../../../base/common/event.js';
import { Disposable, DisposableStore } from '../../../base/common/lifecycle.js';
import { Disposable } from '../../../base/common/lifecycle.js';
import { IProfileStorageValueChangeEvent, IStorageService, StorageScope, StorageTarget } from '../../storage/common/storage.js';
import { adoptToGalleryExtensionId, areSameExtensions, getExtensionId } from './extensionManagementUtil.js';
import { IProductService } from '../../product/common/productService.js';
Expand Down Expand Up @@ -103,7 +103,7 @@ export class ExtensionStorageService extends Disposable implements IExtensionSto
) {
super();
this.extensionsWithKeysForSync = ExtensionStorageService.readAllExtensionsWithKeysForSync(storageService);
this._register(this.storageService.onDidChangeValue(StorageScope.PROFILE, undefined, this._register(new DisposableStore()))(e => this.onDidChangeStorageValue(e)));
this._register(this.storageService.onDidChangeValue(StorageScope.PROFILE, undefined, this._store)(e => this.onDidChangeStorageValue(e)));
}

private onDidChangeStorageValue(e: IProfileStorageValueChangeEvent): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { Emitter, Event } from '../../../base/common/event.js';
import { Disposable, DisposableStore } from '../../../base/common/lifecycle.js';
import { Disposable } from '../../../base/common/lifecycle.js';
import { isWeb } from '../../../base/common/platform.js';
import { IEnvironmentService } from '../../environment/common/environment.js';
import { IApplicationStorageValueChangeEvent, IStorageService, StorageScope, StorageTarget } from '../../storage/common/storage.js';
Expand Down Expand Up @@ -36,7 +36,7 @@ export class UserDataSyncEnablementService extends Disposable implements IUserDa
@IUserDataSyncStoreManagementService private readonly userDataSyncStoreManagementService: IUserDataSyncStoreManagementService,
) {
super();
this._register(storageService.onDidChangeValue(StorageScope.APPLICATION, undefined, this._register(new DisposableStore()))(e => this.onDidStorageChange(e)));
this._register(storageService.onDidChangeValue(StorageScope.APPLICATION, undefined, this._store)(e => this.onDidStorageChange(e)));
}

isEnabled(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2648,7 +2648,7 @@ class LayoutStateModel extends Disposable {
}

// Register for runtime key changes
this._register(this.storageService.onDidChangeValue(StorageScope.PROFILE, undefined, this._register(new DisposableStore()))(storageChangeEvent => {
this._register(this.storageService.onDidChangeValue(StorageScope.PROFILE, undefined, this._store)(storageChangeEvent => {
let key: keyof typeof LayoutStateKeys;
for (key in LayoutStateKeys) {
const stateKey = LayoutStateKeys[key] as WorkbenchLayoutStateKey<StorageKeyType>;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/statusbar/statusbarModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { isStatusbarEntryLocation, IStatusbarEntryPriority, StatusbarAlignment } from '../../../services/statusbar/browser/statusbar.js';
import { hide, show, isAncestorOfActiveElement } from '../../../../base/browser/dom.js';
import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
Expand Down Expand Up @@ -55,7 +55,7 @@ export class StatusbarViewModel extends Disposable {
}

private registerListeners(): void {
this._register(this.storageService.onDidChangeValue(StorageScope.PROFILE, StatusbarViewModel.HIDDEN_ENTRIES_KEY, this._register(new DisposableStore()))(() => this.onDidStorageValueChange()));
this._register(this.storageService.onDidChangeValue(StorageScope.PROFILE, StatusbarViewModel.HIDDEN_ENTRIES_KEY, this._store)(() => this.onDidStorageValueChange()));
}

private onDidStorageValueChange(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { Codicon } from '../../../../base/common/codicons.js';
import { DisposableStore, IDisposable } from '../../../../base/common/lifecycle.js';
import { Disposable, IDisposable } from '../../../../base/common/lifecycle.js';
import { URI } from '../../../../base/common/uri.js';
import { localize, localize2 } from '../../../../nls.js';
import { CommandsRegistry } from '../../../../platform/commands/common/commands.js';
Expand Down Expand Up @@ -38,7 +38,7 @@ export class MovedChatViewPane extends ViewPane {
}
}

export class MoveChatViewContribution implements IWorkbenchContribution {
export class MoveChatViewContribution extends Disposable implements IWorkbenchContribution {

static readonly ID = 'workbench.contrib.chatMovedViewWelcomeView';

Expand All @@ -57,6 +57,8 @@ export class MoveChatViewContribution implements IWorkbenchContribution {
@IConfigurationService private readonly configurationService: IConfigurationService,
@IKeybindingService private readonly keybindingService: IKeybindingService,
) {
super();

this.initialize();
}

Expand Down Expand Up @@ -113,7 +115,7 @@ export class MoveChatViewContribution implements IWorkbenchContribution {
}

private registerListeners(): void {
this.storageService.onDidChangeValue(StorageScope.APPLICATION, MoveChatViewContribution.hideMovedChatWelcomeViewStorageKey, new DisposableStore())(() => this.updateContextKey());
this._register(this.storageService.onDidChangeValue(StorageScope.APPLICATION, MoveChatViewContribution.hideMovedChatWelcomeViewStorageKey, this._store)(() => this.updateContextKey()));
}

private registerCommands(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
this._register(this.authenticationService.onDidChangeSessions((e) => this.onDidChangeSessions(e.event)));

// If another window changes the preferred session storage, reset our cached auth state in memory
this._register(this.storageService.onDidChangeValue(StorageScope.APPLICATION, EditSessionsWorkbenchService.CACHED_SESSION_STORAGE_KEY, this._register(new DisposableStore()))(() => this.onDidChangeStorage()));
this._register(this.storageService.onDidChangeValue(StorageScope.APPLICATION, EditSessionsWorkbenchService.CACHED_SESSION_STORAGE_KEY, this._store)(() => this.onDidChangeStorage()));

this.registerSignInAction();
this.registerResetAuthenticationAction();
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/issue/browser/issueTroubleshoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IExtensionManagementService } from '../../../../platform/extensionManag
import { ExtensionType } from '../../../../platform/extensions/common/extensions.js';
import { IProductService } from '../../../../platform/product/common/productService.js';
import { IWorkbenchIssueService } from '../common/issue.js';
import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { Action2, registerAction2 } from '../../../../platform/actions/common/actions.js';
import { IUserDataProfileImportExportService, IUserDataProfileManagementService, IUserDataProfileService } from '../../../services/userDataProfile/common/userDataProfile.js';
import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js';
Expand Down Expand Up @@ -332,7 +332,7 @@ class IssueTroubleshootUi extends Disposable {
if (troubleshootIssueService.isActive()) {
troubleshootIssueService.resume();
}
this._register(storageService.onDidChangeValue(StorageScope.PROFILE, TroubleshootIssueService.storageKey, this._register(new DisposableStore()))(() => {
this._register(storageService.onDidChangeValue(StorageScope.PROFILE, TroubleshootIssueService.storageKey, this._store)(() => {
this.updateContext();
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Disposable, DisposableStore } from '../../../../../base/common/lifecycle.js';
import { Disposable } from '../../../../../base/common/lifecycle.js';
import { LinkedMap, Touch } from '../../../../../base/common/map.js';
import { localize2 } from '../../../../../nls.js';
import { Categories } from '../../../../../platform/action/common/actionCommonCategories.js';
Expand Down Expand Up @@ -36,7 +36,7 @@ export class NotebookKernelHistoryService extends Disposable implements INoteboo

this._loadState();
this._register(this._storageService.onWillSaveState(() => this._saveState()));
this._register(this._storageService.onDidChangeValue(StorageScope.WORKSPACE, NotebookKernelHistoryService.STORAGE_KEY, this._register(new DisposableStore()))(() => {
this._register(this._storageService.onDidChangeValue(StorageScope.WORKSPACE, NotebookKernelHistoryService.STORAGE_KEY, this._store)(() => {
this._loadState();
}));
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/search/browser/searchView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export class SearchView extends ViewPane {
this._saveSearchHistoryService();
}));

this._register(this.storageService.onDidChangeValue(StorageScope.WORKSPACE, SearchHistoryService.SEARCH_HISTORY_KEY, this._register(new DisposableStore()))(() => {
this._register(this.storageService.onDidChangeValue(StorageScope.WORKSPACE, SearchHistoryService.SEARCH_HISTORY_KEY, this._store)(() => {
const restoredHistory = this.searchHistoryService.load();

if (restoredHistory.include) {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/testing/common/storedValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { Event } from '../../../../base/common/event.js';
import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { IStorageService, IStorageValueChangeEvent, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';

export interface IStoredValueSerialization<T> {
Expand Down Expand Up @@ -49,7 +49,7 @@ export class StoredValue<T> extends Disposable {
this.scope = options.scope;
this.target = options.target;
this.serialization = options.serialization ?? defaultSerialization;
this.onDidChange = this.storage.onDidChangeValue(this.scope, this.key, this._register(new DisposableStore()));
this.onDidChange = this.storage.onDidChangeValue(this.scope, this.key, this._store);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/timeline/browser/timelinePane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class TimelinePane extends ViewPane {
this.timelineExcludeSourcesContext.set(excludedSourcesString);
this.excludedSources = new Set(JSON.parse(excludedSourcesString));

this._register(storageService.onDidChangeValue(StorageScope.PROFILE, 'timeline.excludeSources', this._register(new DisposableStore()))(this.onStorageServiceChanged, this));
this._register(storageService.onDidChangeValue(StorageScope.PROFILE, 'timeline.excludeSources', this._store)(this.onStorageServiceChanged, this));
this._register(configurationService.onDidChangeConfiguration(this.onConfigurationChanged, this));
this._register(timelineService.onDidChangeProviders(this.onProvidersChanged, this));
this._register(timelineService.onDidChangeTimeline(this.onTimelineChanged, this));
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/url/browser/trustedDomainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { WindowIdleValue } from '../../../../base/browser/dom.js';
import { mainWindow } from '../../../../base/browser/window.js';
import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { URI } from '../../../../base/common/uri.js';
import { IInstantiationService, createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
import { IStorageService, StorageScope } from '../../../../platform/storage/common/storage.js';
Expand Down Expand Up @@ -41,7 +41,7 @@ export class TrustedDomainService extends Disposable implements ITrustedDomainSe
});
};
this._staticTrustedDomainsResult = initStaticDomainsResult();
this._register(this._storageService.onDidChangeValue(StorageScope.APPLICATION, TRUSTED_DOMAINS_STORAGE_KEY, this._register(new DisposableStore()))(() => {
this._register(this._storageService.onDidChangeValue(StorageScope.APPLICATION, TRUSTED_DOMAINS_STORAGE_KEY, this._store)(() => {
this._staticTrustedDomainsResult?.dispose();
this._staticTrustedDomainsResult = initStaticDomainsResult();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { distinct } from '../../../../base/common/arrays.js';
import { Emitter } from '../../../../base/common/event.js';
import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
import { IExtensionIgnoredRecommendationsService, IgnoredRecommendationChangeNotification } from './extensionRecommendations.js';
Expand Down Expand Up @@ -37,7 +37,7 @@ export class ExtensionIgnoredRecommendationsService extends Disposable implement
) {
super();
this._globalIgnoredRecommendations = this.getCachedIgnoredRecommendations();
this._register(this.storageService.onDidChangeValue(StorageScope.PROFILE, ignoredRecommendationsStorageKey, this._register(new DisposableStore()))(e => this.onDidStorageChange()));
this._register(this.storageService.onDidChangeValue(StorageScope.PROFILE, ignoredRecommendationsStorageKey, this._store)(() => this.onDidStorageChange()));

this.initIgnoredWorkspaceRecommendations();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
this._register(Event.filter(this.userDataSyncAccountService.onTokenFailed, isSuccessive => !isSuccessive)(() => this.update('token failure')));

this._register(Event.filter(this.authenticationService.onDidChangeSessions, e => this.isSupportedAuthenticationProviderId(e.providerId))(({ event }) => this.onDidChangeSessions(event)));
this._register(this.storageService.onDidChangeValue(StorageScope.APPLICATION, UserDataSyncWorkbenchService.CACHED_SESSION_STORAGE_KEY, this._register(new DisposableStore()))(() => this.onDidChangeStorage()));
this._register(this.storageService.onDidChangeValue(StorageScope.APPLICATION, UserDataSyncWorkbenchService.CACHED_SESSION_STORAGE_KEY, this._store)(() => this.onDidChangeStorage()));
this._register(Event.filter(this.userDataSyncAccountService.onTokenFailed, bailout => bailout)(() => this.onDidAuthFailure()));
this.hasConflicts.set(this.userDataSyncService.conflicts.length > 0);
this._register(this.userDataSyncService.onDidChangeConflicts(conflicts => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
this._onDidChangeViewContainers.fire({ removed: [{ container: viewContainer, location: viewContainerLocation }], added: [] });
}));

this._register(this.storageService.onDidChangeValue(StorageScope.PROFILE, ViewDescriptorService.VIEWS_CUSTOMIZATIONS, this._register(new DisposableStore()))(() => this.onDidStorageChange()));
this._register(this.storageService.onDidChangeValue(StorageScope.PROFILE, ViewDescriptorService.VIEWS_CUSTOMIZATIONS, this._store)(() => this.onDidStorageChange()));

this.extensionService.whenInstalledExtensionsRegistered().then(() => this.whenExtensionsRegistered());

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/services/views/common/viewContainerModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ViewContainer, IViewsRegistry, IViewDescriptor, Extensions as ViewExten
import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
import { Registry } from '../../../../platform/registry/common/platform.js';
import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { Event, Emitter } from '../../../../base/common/event.js';
import { IInstantiationService, ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
import { URI } from '../../../../base/common/uri.js';
Expand Down Expand Up @@ -88,7 +88,7 @@ class ViewDescriptorsState extends Disposable {

this.globalViewsStateStorageId = getViewsStateStorageId(viewContainerStorageId);
this.workspaceViewsStateStorageId = viewContainerStorageId;
this._register(this.storageService.onDidChangeValue(StorageScope.PROFILE, this.globalViewsStateStorageId, this._register(new DisposableStore()))(() => this.onDidStorageChange()));
this._register(this.storageService.onDidChangeValue(StorageScope.PROFILE, this.globalViewsStateStorageId, this._store)(() => this.onDidStorageChange()));

this.state = this.initialize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Emitter } from '../../../../base/common/event.js';
import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
import { isTemporaryWorkspace, IWorkspaceContextService, IWorkspaceFoldersChangeEvent, IWorkspaceIdentifier, WorkbenchState, WORKSPACE_EXTENSION } from '../../../../platform/workspace/common/workspace.js';
import { ILogService } from '../../../../platform/log/common/log.js';
import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { getWorkspaceIdentifier } from './workspaces.js';
import { IFileService, FileOperationError, FileOperationResult } from '../../../../platform/files/common/files.js';
import { IWorkbenchEnvironmentService } from '../../environment/common/environmentService.js';
Expand Down Expand Up @@ -49,7 +49,7 @@ export class BrowserWorkspacesService extends Disposable implements IWorkspacesS
private registerListeners(): void {

// Storage
this._register(this.storageService.onDidChangeValue(StorageScope.APPLICATION, BrowserWorkspacesService.RECENTLY_OPENED_KEY, this._register(new DisposableStore()))(() => this._onRecentlyOpenedChange.fire()));
this._register(this.storageService.onDidChangeValue(StorageScope.APPLICATION, BrowserWorkspacesService.RECENTLY_OPENED_KEY, this._store)(() => this._onRecentlyOpenedChange.fire()));

// Workspace
this._register(this.contextService.onDidChangeWorkspaceFolders(e => this.onDidChangeWorkspaceFolders(e)));
Expand Down
Loading

0 comments on commit b402ee3

Please sign in to comment.