(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:
George Gevoian
2022-06-06 09:21:26 -07:00
parent ff77ecc6c6
commit 090d9af21d
15 changed files with 278 additions and 129 deletions

View File

@@ -63,6 +63,14 @@ import {Events as BackboneEvents} from 'backbone';
* @property {Boolean} fromSelf - Flag to indicate whether the action originated from this client.
*/
/**
* Event for a change to document usage. Sent to all clients that have this document open.
* @event docUsage
* @property {Number} docFD - The file descriptor of the open document, specific to each client.
* @property {FilteredDocUsageSummary} data.docUsage - Document usage summary.
* @property {Product} data.product - Product that was used to compute `data.docUsage`
*/
/**
* Event for when a document is forcibly shutdown, and requires the client to re-open it.
* @event docShutdown
@@ -111,7 +119,7 @@ import {Events as BackboneEvents} from 'backbone';
*/
const ValidEvent = StringUnion('docListAction', 'docUserAction', 'docShutdown', 'docError',
'clientConnect', 'clientLogout',
'docUsage', 'clientConnect', 'clientLogout',
'profileFetch', 'userSettings', 'receiveInvites');
type ValidEvent = typeof ValidEvent.type;