From f28f37b5a81033775fcce768f3e95122d7f5fb94 Mon Sep 17 00:00:00 2001 From: Zuzanna Date: Fri, 13 Feb 2026 13:36:10 +0100 Subject: [PATCH 1/4] fix for timeline position & iterating over reverted checkpoints --- www/common/onlyoffice/history.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/www/common/onlyoffice/history.js b/www/common/onlyoffice/history.js index 68a542ec2..c994f1a05 100644 --- a/www/common/onlyoffice/history.js +++ b/www/common/onlyoffice/history.js @@ -38,6 +38,7 @@ define([ var currentVersion; var forward; var revertCheckpoint; + var previousRevertCheckpoint; // Get an array of the checkpoint IDs sorted their patch index var hashes = config.onlyoffice.hashes; @@ -107,14 +108,20 @@ define([ messages = (data.messages || []).slice(1); } + if (revertCheckpoint && !forward) { + previousRevertCheckpoint = revertCheckpoint; + } + if (messages[0] && isEmptyPatch(JSON.parse(messages[0].msg))) { - revertCheckpoint = true; + revertCheckpoint = false; messages.splice(0, 1); } else if (messages[1] && isEmptyPatch(JSON.parse(messages[1].msg))) { - revertCheckpoint = true; - messages.splice(1, 1); - } else { revertCheckpoint = false; + messages.splice(1, 1); + } else if (id === 0) { + revertCheckpoint = false; + } else { + revertCheckpoint = true; } if (config.debug) { console.log(data.messages); } @@ -292,8 +299,8 @@ define([ }); if (initial) { snapshotsEl.push(finalpatchDiv); - } else { - firstCp ? snapshotsEl.splice(msgs?.length, 0, finalpatchDiv) : snapshotsEl.splice(msgs?.length-1, 0, finalpatchDiv); + } else if (previousRevertCheckpoint) { + snapshotsEl.splice(msgs.length, 0, finalpatchDiv); } if (!msgsRev.length && !Object.keys(hashes).length || initial && !msgs?.length) { @@ -406,7 +413,7 @@ define([ return; } //Is the checkpoint the result of restoring history? If yes, we need to load an extra patch - if (revertCheckpoint ) { + if (!revertCheckpoint) { msgIndex = -msgs?.length; config.onPatchBack(hashes[id], [msgs[0]]); position = 1; @@ -474,9 +481,10 @@ define([ patch = msgs[msgs?.length-1]; //Is the checkpoint the result of restoring history? If yes, we need to load an extra patch - if (isRevert) { + if (!isRevert) { config.onPatchBack(cp, q); msgIndex--; + position = msgs?.length-1; } else { restore = true; if (!$(`[data="${id},${position}"]`).length) { From b292b94b6c29535c0a58d53061eea915c03724fa Mon Sep 17 00:00:00 2001 From: Zuzanna Date: Fri, 13 Feb 2026 13:39:24 +0100 Subject: [PATCH 2/4] linting --- www/common/onlyoffice/history.js | 1 - 1 file changed, 1 deletion(-) diff --git a/www/common/onlyoffice/history.js b/www/common/onlyoffice/history.js index c994f1a05..b50f65b11 100644 --- a/www/common/onlyoffice/history.js +++ b/www/common/onlyoffice/history.js @@ -267,7 +267,6 @@ define([ var patchWidth; var patchDiv; - var firstCp = (id === 0) ? true : false; for (var i = 0; i < msgsRev.length; i++) { var msg = msgs[i]; if (initial || id === -1) { From 8b227059efb2bee4be0ffb52247d48d0090fbbc4 Mon Sep 17 00:00:00 2001 From: Zuzanna Date: Tue, 24 Feb 2026 11:51:56 +0100 Subject: [PATCH 3/4] fix for history loading issues due to latency --- www/common/onlyoffice/history.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/onlyoffice/history.js b/www/common/onlyoffice/history.js index b50f65b11..8c5517db4 100644 --- a/www/common/onlyoffice/history.js +++ b/www/common/onlyoffice/history.js @@ -514,7 +514,7 @@ define([ setTimeout(() => { displayCheckpointTimeline(true); showVersion(true); - }, "1000"); + }, "2500"); // Create the history toolbar var display = function () { From 40c8cc12d463cf64b2e609b7129e0d4a89ca2dce Mon Sep 17 00:00:00 2001 From: Zuzanna Date: Thu, 26 Feb 2026 11:25:26 +0100 Subject: [PATCH 4/4] imrpved fix for latency issue --- www/common/onlyoffice/history.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/www/common/onlyoffice/history.js b/www/common/onlyoffice/history.js index 8c5517db4..7893510e6 100644 --- a/www/common/onlyoffice/history.js +++ b/www/common/onlyoffice/history.js @@ -168,7 +168,10 @@ define([ }); }; - loadMoreOOHistory(); + loadMoreOOHistory().then(() => { + displayCheckpointTimeline(true); + showVersion(true); + }) var onClose = function () { config.setHistory(false); }; var onRevert = function () { @@ -511,10 +514,6 @@ define([ }; - setTimeout(() => { - displayCheckpointTimeline(true); - showVersion(true); - }, "2500"); // Create the history toolbar var display = function () {