clean up properly

This commit is contained in:
Bruno Windels 2020-11-10 19:05:50 +01:00
parent d14f485292
commit c65e8bea11
2 changed files with 4 additions and 1 deletions

View File

@ -12,6 +12,7 @@
link.href = url; link.href = url;
link.download = filename; link.download = filename;
link.click(); link.click();
URL.revokeObjectURL(url);
} }
window.addEventListener("message", function(event) { window.addEventListener("message", function(event) {
if (event.data.type === "download") { if (event.data.type === "download") {

View File

@ -33,12 +33,14 @@ export class FileTile extends MessageTile {
const filename = content.body; const filename = content.body;
this._downloading = true; this._downloading = true;
this.emitChange("label"); this.emitChange("label");
let bufferHandle;
try { try {
const bufferHandle = await this._mediaRepository.downloadAttachment(content); bufferHandle = await this._mediaRepository.downloadAttachment(content);
this.platform.offerSaveBufferHandle(bufferHandle, filename); this.platform.offerSaveBufferHandle(bufferHandle, filename);
} catch (err) { } catch (err) {
this._error = err; this._error = err;
} finally { } finally {
bufferHandle?.dispose();
this._downloading = false; this._downloading = false;
} }
this.emitChange("label"); this.emitChange("label");