mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) do not look at content of recent actions when loading documents
Summary: This removes the need for any information drawn from the content of recent actions when loading a document. The undo/redo system does need some facts about recent actions up front. But that system has an important restriction: only actions a particular client is known to have generated can be undone by that client. So in this diff, as we store which client has performed an action, we also store the few pieces of metadata about that action that the undo/redo system needs: `linkId`, `otherId`, `rowIdHint`, `isUndo` fields. These are all small integers (or in one case a boolean). An existing limitation is that information about which client has performed which action is stored in memory in the worker, and not persisted anywhere. This diff does not change that limitation, meaning that undos continue to not survive a worker transition. A reasonable way to deal with that would be to back the store with redis. Test Plan: existing tests pass Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D3044
This commit is contained in:
@@ -14,7 +14,7 @@ import {shortDesc} from 'app/server/lib/shortDesc';
|
||||
import * as assert from 'assert';
|
||||
import {Mutex} from 'async-mutex';
|
||||
import * as Deque from 'double-ended-queue';
|
||||
import {ActionHistory, asActionGroup} from './ActionHistory';
|
||||
import { ActionHistory, asActionGroup, getActionUndoInfo} from './ActionHistory';
|
||||
import {summarizeAction} from "./ActionSummary";
|
||||
import {ActiveDoc} from './ActiveDoc';
|
||||
import {makeExceptionalDocSession, OptDocSession} from './DocSession';
|
||||
@@ -275,7 +275,9 @@ export class Sharing {
|
||||
// Check isCalculate because that's not an action we should allow undo/redo for (it's not
|
||||
// considered as performed by a particular client).
|
||||
if (client && client.clientId && !isCalculate) {
|
||||
this._actionHistory.setActionClientId(localActionBundle.actionHash!, client.clientId);
|
||||
this._actionHistory.setActionUndoInfo(
|
||||
localActionBundle.actionHash!,
|
||||
getActionUndoInfo(localActionBundle, client.clientId, sandboxActionBundle.retValues));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -286,7 +288,7 @@ export class Sharing {
|
||||
|
||||
// Broadcast the action to connected browsers.
|
||||
const actionGroup = asActionGroup(this._actionHistory, localActionBundle, {
|
||||
client,
|
||||
clientId: client?.clientId,
|
||||
retValues: sandboxActionBundle.retValues,
|
||||
// Mark the on-open Calculate action as internal. In future, synchronizing fields to today's
|
||||
// date and other changes from external values may count as internal.
|
||||
|
||||
Reference in New Issue
Block a user