From bfe4f3ba36ee6393a1e0006e9749258a094d08fb Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 19 Aug 2021 16:00:50 +0200 Subject: [PATCH] Fix race condition when downloading sheets --- www/common/onlyoffice/history.js | 2 +- www/common/onlyoffice/inner.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/www/common/onlyoffice/history.js b/www/common/onlyoffice/history.js index b8ae4b77d..c0126023c 100644 --- a/www/common/onlyoffice/history.js +++ b/www/common/onlyoffice/history.js @@ -119,7 +119,7 @@ define([ // The first "cp" in history is the empty doc. It doesn't include the first patch // of the history - var initialCp = cpIndex === sortedCp.length; + var initialCp = cpIndex === sortedCp.length || !cp.hash; var messages = (data.messages || []).slice(initialCp ? 0 : 1); diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index c5adfa928..f1c10261d 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -726,7 +726,7 @@ define([ // The first "cp" in history is the empty doc. It doesn't include the first patch // of the history - var initialCp = major === 0; + var initialCp = major === 0 || !cp.hash; var messages = (data.messages || []).slice(initialCp ? 0 : 1, minor); messages.forEach(function (obj) { @@ -1719,11 +1719,11 @@ define([ // store media blobUrl and content for cache and export var mediaData = { blobUrl : blobUrl, content : "" }; mediasData[data.src] = mediaData; - downloadImages[name].fire(); var reader = new FileReader(); reader.onloadend = function () { debug("MediaData set"); mediaData.content = reader.result; + downloadImages[name].fire(); }; reader.readAsArrayBuffer(res.content); debug("Adding CryptPad Image " + data.name + ": " + blobUrl);