Fix images in onlyoffice

pull/1/head
yflory 5 years ago
parent b76d308db8
commit 7b026868fd

@ -674,6 +674,11 @@ define([
case "saveChanges": case "saveChanges":
// We're sending our changes to netflux // We're sending our changes to netflux
handleChanges(obj, send); handleChanges(obj, send);
// If we're alone, clean up the medias
var m = metadataMgr.getChannelMembers().slice().filter(function (nId) {
return nId.length === 32;
});
if (m.length === 1 && !APP.loadingImage) {
try { try {
var docs = window.frames[0].AscCommon.g_oDocumentUrls.urls || {}; var docs = window.frames[0].AscCommon.g_oDocumentUrls.urls || {};
var mediasSources = getMediasSources(); var mediasSources = getMediasSources();
@ -684,6 +689,7 @@ define([
}); });
APP.onLocal(); APP.onLocal();
} catch (e) {} } catch (e) {}
}
break; break;
case "unLockDocument": case "unLockDocument":
if (obj.releaseLocks && content.locks && content.locks[getId()]) { if (obj.releaseLocks && content.locks && content.locks[getId()]) {
@ -829,6 +835,7 @@ define([
}); });
}; };
APP.loadingImage = 0;
APP.getImageURL = function(name, callback) { APP.getImageURL = function(name, callback) {
var mediasSources = getMediasSources(); var mediasSources = getMediasSources();
var data = mediasSources[name]; var data = mediasSources[name];
@ -844,10 +851,16 @@ define([
return void callback(blobUrl); return void callback(blobUrl);
} }
APP.loadingImage++;
Util.fetch(data.src, function (err, u8) { Util.fetch(data.src, function (err, u8) {
if (err) {
APP.loadingImage--;
return void console.error(err);
}
try { try {
debug("Decrypt with key " + data.key); debug("Decrypt with key " + data.key);
FileCrypto.decrypt(u8, Nacl.util.decodeBase64(data.key), function (err, res) { FileCrypto.decrypt(u8, Nacl.util.decodeBase64(data.key), function (err, res) {
APP.loadingImage--;
if (err || !res.content) { if (err || !res.content) {
debug("Decrypting failed"); debug("Decrypting failed");
return void callback(""); return void callback("");
@ -868,6 +881,7 @@ define([
callback(blobUrl); callback(blobUrl);
}); });
} catch (e) { } catch (e) {
APP.loadingImage--;
debug("Exception decrypting image " + data.name); debug("Exception decrypting image " + data.name);
console.error(e); console.error(e);
callback(""); callback("");

Loading…
Cancel
Save