Every message opened kept its full copy for as long as the tab was open. The store now holds bodies for the 40 messages most recently wanted; older ones go back to the list properties and are fetched in full again if opened. The open conversation is never released. Contact, settings and calendar exports go through downloadFile, which releases the object URL once the download has started; three of them never released it.
17 lines
600 B
TypeScript
17 lines
600 B
TypeScript
/**
|
|
* Hand the browser a file the app made, to save.
|
|
*
|
|
* The object URL is released as soon as the download has been started: a
|
|
* click on the link starts it synchronously, and an unreleased URL keeps the
|
|
* whole file in memory for as long as the tab is open -- an address book's
|
|
* worth of vCards, per export.
|
|
*/
|
|
export function downloadFile(content: BlobPart, type: string, filename: string): void {
|
|
const url = URL.createObjectURL(new Blob([content], { type }));
|
|
const a = document.createElement("a");
|
|
a.href = url;
|
|
a.download = filename;
|
|
a.click();
|
|
URL.revokeObjectURL(url);
|
|
}
|