mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Broadcast doc usage updates to clients
Summary: Introduces a new message type, docUsage, that's broadcast to all connected clients whenever document usage is updated in ActiveDoc. Test Plan: Browser tests. Reviewers: jarek Reviewed By: jarek Differential Revision: https://phab.getgrist.com/D3451
This commit is contained in:
@@ -7,7 +7,6 @@ import {AppModel, reportError} from 'app/client/models/AppModel';
|
||||
import {reportMessage, UserError} from 'app/client/models/errors';
|
||||
import {urlState} from 'app/client/models/gristUrlState';
|
||||
import {ownerName} from 'app/client/models/WorkspaceInfo';
|
||||
import {OrgUsageSummary} from 'app/common/DocUsage';
|
||||
import {IHomePage} from 'app/common/gristUrls';
|
||||
import {isLongerThan} from 'app/common/gutil';
|
||||
import {SortPref, UserOrgPrefs, ViewPref} from 'app/common/Prefs';
|
||||
@@ -76,8 +75,6 @@ export interface HomeModel {
|
||||
// user isn't allowed to create a doc.
|
||||
newDocWorkspace: Observable<Workspace|null|"unsaved">;
|
||||
|
||||
currentOrgUsage: Observable<OrgUsageSummary|null>;
|
||||
|
||||
createWorkspace(name: string): Promise<void>;
|
||||
renameWorkspace(id: number, name: string): Promise<void>;
|
||||
deleteWorkspace(id: number, forever: boolean): Promise<void>;
|
||||
@@ -158,8 +155,6 @@ export class HomeModelImpl extends Disposable implements HomeModel, ViewSettings
|
||||
wss.every((ws) => ws.isSupportWorkspace || ws.docs.length === 0) &&
|
||||
Boolean(use(this.newDocWorkspace))));
|
||||
|
||||
public readonly currentOrgUsage: Observable<OrgUsageSummary|null> = Observable.create(this, null);
|
||||
|
||||
private _userOrgPrefs = Observable.create<UserOrgPrefs|undefined>(this, this._app.currentOrg?.userOrgPrefs);
|
||||
|
||||
constructor(private _app: AppModel, clientScope: ClientScope) {
|
||||
@@ -193,7 +188,7 @@ export class HomeModelImpl extends Disposable implements HomeModel, ViewSettings
|
||||
const importSources = ImportSourceElement.fromArray(pluginManager.pluginsList);
|
||||
this.importSources.set(importSources);
|
||||
|
||||
this._updateCurrentOrgUsage().catch(reportError);
|
||||
this._app.refreshOrgUsage().catch(reportError);
|
||||
}
|
||||
|
||||
// Accessor for the AppModel containing this HomeModel.
|
||||
@@ -386,14 +381,6 @@ export class HomeModelImpl extends Disposable implements HomeModel, ViewSettings
|
||||
await this._app.api.updateOrg('current', {userOrgPrefs: org.userOrgPrefs});
|
||||
}
|
||||
}
|
||||
|
||||
private async _updateCurrentOrgUsage() {
|
||||
const currentOrg = this.app.currentOrg;
|
||||
if (!roles.isOwner(currentOrg)) { return; }
|
||||
|
||||
const api = this.app.api;
|
||||
this.currentOrgUsage.set(await api.getOrgUsageSummary(currentOrg.id));
|
||||
}
|
||||
}
|
||||
|
||||
// Check if active product allows just a single workspace.
|
||||
|
||||
Reference in New Issue
Block a user