From b14490d6aa3832685eccca641fc1b36551a418d7 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Thu, 27 Mar 2025 08:54:36 +0000 Subject: [PATCH] Avoid setting pendingOpCreatedAt for remote changes (#24542) GitOrigin-RevId: 5d1684a743825cac23d486678b8f249cf0d152d8 --- .../web/frontend/js/features/ide-react/editor/share-js-doc.ts | 3 ++- services/web/frontend/js/vendor/libs/sharejs.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/services/web/frontend/js/features/ide-react/editor/share-js-doc.ts b/services/web/frontend/js/features/ide-react/editor/share-js-doc.ts index ef6a6d3776..b56d6443dd 100644 --- a/services/web/frontend/js/features/ide-react/editor/share-js-doc.ts +++ b/services/web/frontend/js/features/ide-react/editor/share-js-doc.ts @@ -93,7 +93,8 @@ export class ShareJsDoc extends EventEmitter { }) this._doc.setFlushDelay(SINGLE_USER_FLUSH_DELAY) this._doc.on('change', (...args: any[]) => { - if (!this.pendingOpCreatedAt) { + const isRemote = args[3] + if (!isRemote && !this.pendingOpCreatedAt) { debugConsole.log('set pendingOpCreatedAt', new Date()) this.pendingOpCreatedAt = performance.now() } diff --git a/services/web/frontend/js/vendor/libs/sharejs.js b/services/web/frontend/js/vendor/libs/sharejs.js index ffaf0ea4fb..a8bbdfaa78 100644 --- a/services/web/frontend/js/vendor/libs/sharejs.js +++ b/services/web/frontend/js/vendor/libs/sharejs.js @@ -959,7 +959,7 @@ export const { Doc } = (() => { // Its important that these event handlers are called with oldSnapshot. // The reason is that the OT type APIs might need to access the snapshots to // determine information about the received op. - this.emit('change', docOp, oldSnapshot, msg); + this.emit('change', docOp, oldSnapshot, msg, isRemote); if (isRemote) { return this.emit('remoteop', docOp, oldSnapshot, msg); }