From c32593e49875f1ddbbfff129686dc60d9a704f4d Mon Sep 17 00:00:00 2001 From: Zuzanna Date: Tue, 9 Sep 2025 15:25:00 +0200 Subject: [PATCH] wip --- www/common/onlyoffice/history.js | 28 ++++++++++++++-------------- www/common/onlyoffice/inner.js | 21 +-------------------- 2 files changed, 15 insertions(+), 34 deletions(-) diff --git a/www/common/onlyoffice/history.js b/www/common/onlyoffice/history.js index b7a0bb522..88f7e5175 100644 --- a/www/common/onlyoffice/history.js +++ b/www/common/onlyoffice/history.js @@ -43,8 +43,10 @@ define([ var fillOO = function (id, messages) { if (!id) { return; } - if (ooMessages[id]) { return; } + // if (ooMessages[id]) { return; } + ooMessages[id] = messages; + update(); }; @@ -105,7 +107,7 @@ define([ if (config.debug) { console.log(data.messages); } - + id = getId() fillOO(id, messages); loading = false; // $share.show(); @@ -116,6 +118,7 @@ define([ // We want to load a checkpoint (or initial state) var loadMoreOOHistory = function () { + if (!Array.isArray(sortedCp)) { return void console.error("Wrong type"); } var cp = {}; @@ -141,7 +144,7 @@ define([ // Next cp or last hash var fromHash = nextId ? hashes[nextId].hash : config.onlyoffice.lastHash; - msgIndex = -1; + // msgIndex = -1; showVersion(); if (ooMessages[id]) { @@ -167,8 +170,8 @@ define([ }); var onClose = function () { config.setHistory(false); }; - var onRevert = function (msgs) { - config.onRevert(msgs); + var onRevert = function () { + config.onRevert(); }; config.setHistory(true); @@ -183,7 +186,7 @@ define([ var getId = function () { var cps = sortedCp.length; - return sortedCp[cps - cpIndex -1] || -1; + return sortedCp[cps-1] || -1; }; update = function () { @@ -204,13 +207,13 @@ define([ var id = getId(); var msgs = (ooMessages[id] || []).length; var v = getVersion() - if (msgIndex >= (msgs-1) || v === '1.0') { + if (msgIndex >= (msgs-1)) { $next.prop('disabled', 'disabled'); } }; var next = function () { - var id = -1 + var id = getId() if (!ooMessages[id]) { loading = false; return; } var msgs = ooMessages[id]; var cp = ooCheckpoints[id]; @@ -228,16 +231,14 @@ define([ var prev = function () { var id = getId(); - var msgs = ooMessages[-1]; + var msgs = ooMessages[id]; var cp = ooCheckpoints[id]; var queue = msgs.slice(0, msgIndex); config.onPatchBack(cp, queue, newlyLoaded); newlyLoaded = false showVersion(); - msgIndex--; - }; @@ -344,7 +345,7 @@ define([ $prev.click(function () { // if (loading) { return; } loading = true; - // loadMoreOOHistory(); + loadMoreOOHistory(); prev(); update(); }); @@ -434,8 +435,7 @@ define([ if (!yes) { return; } closeUI(); History.loading = false; - console.log("messages2", ooMessages[-1]) - onRevert(ooMessages[-1]); + onRevert(); UI.log(Messages.history_restoreDone); }); }); diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index ca6ebf85c..4c08eb0bf 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -588,7 +588,6 @@ define([ }; var saveToServer = function (blob, title, msgs) { - APP.msgs = msgs if (APP.cantCheckpoint) { return; } // TOO_LARGE var text = !blob && getContent(); if (!text && !blob) { @@ -1094,22 +1093,7 @@ define([ const getInitialChanges = function() { const changes = []; - if (APP.msgs) { - msgsFormatted = [] - APP.msgs.forEach(function(msg) { - var parsedMsg = JSON.parse(msg.msg); - var formattedMsg = { - msg: parsedMsg, - hash: msg.serverHash, - author: msg.author, - time: msg.time - }; - - msgsFormatted.push(formattedMsg) - }) - ooChannel.queue = msgsFormatted - } if (content.version > 2) { ooChannel.queue.forEach(function (data) { Array.prototype.push.apply(changes, data.msg.changes); @@ -1120,7 +1104,6 @@ define([ var last = ooChannel.queue.pop(); if (last) { ooChannel.lastHash = last.hash; } } - APP.msgs = false return changes }; @@ -3185,15 +3168,13 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null if (newlyLoaded) { originalHistory = ooChannel.queue } - // We want to load a checkpoint: msgsFormatted = [] msgs.forEach(function(msg) { var parsedMsg = JSON.parse(msg.msg); - // Create the new format2 object structure var formattedMsg = { msg: parsedMsg, - hash: msg.serverHash, // Map serverHash to hash + hash: msg.serverHash, author: msg.author, time: msg.time };