Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ViewManagerModel.api private #3863

Merged
merged 9 commits into from
Dec 18, 2024
21 changes: 14 additions & 7 deletions cmp/viewmanager/ViewManagerModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {runInAction} from 'mobx';
import {ReactNode} from 'react';
import {ViewInfo} from './ViewInfo';
import {View} from './View';
import {ViewToBlobApi, ViewCreateSpec} from './ViewToBlobApi';
import {ViewToBlobApi, ViewCreateSpec, ViewUpdateSpec} from './ViewToBlobApi';

export interface ViewManagerConfig {
/**
Expand Down Expand Up @@ -201,13 +201,10 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
*/
providers: ViewManagerProvider<any>[] = [];

/**
* Data access for persisting views.
* @internal
*/
api: ViewToBlobApi<T>;
/** Data access for persisting views. */
private api: ViewToBlobApi<T>;

// Last time changes were pushed to linked persistence providers
/** Last time changes were pushed to linked persistence providers */
private lastPushed: number = null;

//---------------
Expand Down Expand Up @@ -442,6 +439,16 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
return null;
}

/** Update all aspects of a view's metadata.*/
async updateViewInfoAsync(view: ViewInfo, updates: ViewUpdateSpec): Promise<View<T>> {
return this.api.updateViewInfoAsync(view, updates);
}

/** Promote a view to global visibility/ownership status. */
async makeViewGlobalAsync(view: ViewInfo): Promise<View<T>> {
return this.api.makeViewGlobalAsync(view);
}

async deleteViewsAsync(toDelete: ViewInfo[]): Promise<void> {
let exception;
try {
Expand Down
4 changes: 2 additions & 2 deletions desktop/cmp/viewmanager/dialog/ManageDialogModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class ManageDialogModel extends HoistModel {

private async doUpdateAsync(view: ViewInfo, update: ViewUpdateSpec) {
const {viewManagerModel} = this;
await viewManagerModel.api.updateViewInfoAsync(view, update);
await viewManagerModel.updateViewInfoAsync(view, update);
await viewManagerModel.refreshAsync();
await this.refreshAsync();
}
Expand Down Expand Up @@ -235,7 +235,7 @@ export class ManageDialogModel extends HoistModel {
if (!confirmed) return;

const {viewManagerModel} = this;
const updated = await viewManagerModel.api.makeViewGlobalAsync(view);
const updated = await viewManagerModel.makeViewGlobalAsync(view);
await viewManagerModel.refreshAsync();
await this.refreshAsync();
await this.selectViewAsync(updated.info); // reselect -- will have moved tabs!
Expand Down
Loading