Fix images in onlyoffice

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

@ -674,16 +674,22 @@ 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);
try { // If we're alone, clean up the medias
var docs = window.frames[0].AscCommon.g_oDocumentUrls.urls || {}; var m = metadataMgr.getChannelMembers().slice().filter(function (nId) {
var mediasSources = getMediasSources(); return nId.length === 32;
Object.keys(mediasSources).forEach(function (name) { });
if (!docs['media/'+name]) { if (m.length === 1 && !APP.loadingImage) {
delete mediasSources[name]; try {
} var docs = window.frames[0].AscCommon.g_oDocumentUrls.urls || {};
}); var mediasSources = getMediasSources();
APP.onLocal(); Object.keys(mediasSources).forEach(function (name) {
} catch (e) {} if (!docs['media/'+name]) {
delete mediasSources[name];
}
});
APP.onLocal();
} 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