From 2172e1405ca6d0c9e51ce293ed110b91d3e9d516 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 22 Feb 2021 13:27:30 +0100 Subject: [PATCH] Test improved lock --- www/common/onlyoffice/inner.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 5f19879b3..b0f764913 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -989,6 +989,7 @@ define([ deleteOfflineLocks(); // Prepare callback if (cpNfInner) { + APP.waitLock = Util.mkEvent(true); var onPatchSent = function (again) { if (!again) { cpNfInner.offPatchSent(onPatchSent); } // Answer to our onlyoffice @@ -1004,6 +1005,8 @@ define([ type: "getLock", locks: getLock() }); + APP.waitLock.fire(); + delete APP.waitLock; } else { if (!isLockedModal.modal) { isLockedModal.modal = UI.openCustomModal(isLockedModal.content); @@ -1127,10 +1130,19 @@ define([ case "isSaveLock": // TODO ping the server to check if we're online first? if (!offline) { - send({ - type: "saveLock", - saveLock: false - }, true); + if (APP.waitLock) { + APP.waitLock.reg(function () { + send({ + type: "saveLock", + saveLock: false + }, true); + }); + } else { + send({ + type: "saveLock", + saveLock: false + }, true); + } } break; case "getLock":