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.download = filename;
link.click();
URL.revokeObjectURL(url);
}
window.addEventListener("message", function(event) {
if (event.data.type === "download") {

View file

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