Properly cleanup an image when it is removed

This commit is contained in:
Timothy Farrell 2017-12-16 04:58:51 -06:00
parent 6295d9b177
commit 03f992811d

View File

@ -31,11 +31,11 @@ async function loadImageFromBlob(doc, evt, node, vm) {
}
}
function cleanup(id, evt) {
const { src } = evt.target;
function cleanup(node) {
const src = node.el.src;
if (src.startsWith('blob:')) {
URL.revokeObjectURL(s);
srcMap.remove(id);
URL.revokeObjectURL(src);
srcMap.delete(node.key);
}
}
@ -50,7 +50,7 @@ export function AttachmentImageView(doc, props) {
onerror: [loadImageFromBlob, doc],
_key: _id,
_hooks: {
didRemove: [cleanup, _id]
willRemove: cleanup
}
},
props || {}