Fixed callback in case of error on image fetching

pull/1/head
Ludovic Dubost 5 years ago
parent 9b2e4816c8
commit 1c19e6f2b5

@ -773,9 +773,10 @@ define([
var item = params[i].split("="); var item = params[i].split("=");
data[item[0]] = decodeURIComponent(item[1]); data[item[0]] = decodeURIComponent(item[1]);
} }
Util.fetch(data.src, function (err, u8) { Util.fetch(data.src, function (err, u8) {
FileCrypto.decrypt(u8, Nacl.util.decodeBase64(data.key), function (err, res) { FileCrypto.decrypt(u8, Nacl.util.decodeBase64(data.key), function (err, res) {
if (err || !res.content) { return APP.AddImageErrorCallback(err); } if (err || !res.content) { callback(); }
var url = URL.createObjectURL(res.content) + "#" + hiddendata; var url = URL.createObjectURL(res.content) + "#" + hiddendata;
// store media content for potential export // store media content for potential export
var reader = new FileReader(); var reader = new FileReader();
@ -783,6 +784,7 @@ define([
mediasContent[data.name + "#" + hiddendata] = reader.result; mediasContent[data.name + "#" + hiddendata] = reader.result;
} }
reader.readAsArrayBuffer(res.content); reader.readAsArrayBuffer(res.content);
console.log("Adding CryptPad Image " + data.name + ": " + url);
window.frames[0].AscCommon.g_oDocumentUrls.addImageUrl(data.name + "#" + hiddendata, url); window.frames[0].AscCommon.g_oDocumentUrls.addImageUrl(data.name + "#" + hiddendata, url);
callback(url); callback(url);
}); });

Loading…
Cancel
Save