MCPcopy Create free account
hub / github.com/apitable/apitable / handleAcceptCommit

Method handleAcceptCommit

packages/core/src/engine/engine.ts:254–285  ·  view source on GitHub ↗

* The submitted changeset is accepted by the service

(remoteChangeset: IRemoteChangeset)

Source from the content-addressed store, hash-verified

252 * The submitted changeset is accepted by the service
253 */
254 async handleAcceptCommit(remoteChangeset: IRemoteChangeset) {
255 // Check version continuity, if not, add it first.
256 await this.checkMissChanges(remoteChangeset.revision);
257 const revision = this.getRevision();
258 // This may happen when entering the table for the first time.
259 // The client detects that there is still local content that cannot be sent, so it re-sends
260 if (!this.bufferStorage.localPendingChangeset) {
261 Player.doTrigger(Events.app_error_logger, {
262 error: new Error('missing localChangeset when receiving ACK'),
263 });
264 return;
265 }
266 if (
267 revision != null &&
268 remoteChangeset?.messageId === this.bufferStorage.localPendingChangeset?.messageId &&
269 remoteChangeset?.revision === revision + 1
270 ) {
271 const filteredOperations = remoteChangeset.operations.filter(op => {
272 return (op.cmd === CollaCommandName.SystemSetRecords || op.cmd === CollaCommandName.SystemSetFieldAttr);
273 });
274
275 if (filteredOperations.length) {
276 this.event.onAcceptSystemOperations(filteredOperations);
277 }
278 this.handleSubscriptions(remoteChangeset);
279
280 this.dispatch(updateRevision(revision + 1, this.resourceId, this.resourceType));
281 return;
282 }
283 console.error('ACK data error', { revision, ack: remoteChangeset, localChangeset: this.bufferStorage.localPendingChangeset });
284 throw new Error('Data returned in wrong format, please refresh and try again');
285 }
286
287 /**
288 * @param startRevision inclusive

Callers 1

applyNewChangesMethod · 0.95

Calls 7

checkMissChangesMethod · 0.95
handleSubscriptionsMethod · 0.95
updateRevisionFunction · 0.90
errorMethod · 0.65
getRevisionMethod · 0.45
filterMethod · 0.45
dispatchMethod · 0.45

Tested by

no test coverage detected