diff --git a/src/components/DataExportSection.vue b/src/components/DataExportSection.vue
index cfbc2dea..a5c31ace 100644
--- a/src/components/DataExportSection.vue
+++ b/src/components/DataExportSection.vue
@@ -1,9 +1,12 @@
/** * Data Export Section Component * * Provides UI and functionality for
exporting user data and backing up identifier seeds. * Includes buttons for seed
backup and database export, with platform-specific download instructions. * *
-@component * @displayName DataExportSection * @example * ```vue *
+Features: * - Platform-specific export handling (web vs. native) * - Proper
+resource cleanup for blob URLs * - Robust error handling with user-friendly
+messages * - Conditional UI based on platform capabilities * * @component *
+@displayName DataExportSection * @example * ```vue *
-* ``` */
+* ``` * * @author Matthew Raymer * @since 2025-01-25 * @version 1.1.0 */
Download Contacts
+
+
If no download happened yet, click again here to download now.
@@ -97,8 +103,11 @@ export default class DataExportSection extends Vue {
/**
* Notification helper for consistent notification patterns
+ * Created as a getter to ensure $notify is available when called
*/
- notify = createNotifyHelpers(this.$notify);
+ get notify() {
+ return createNotifyHelpers(this.$notify);
+ }
/**
* NOTE: PlatformServiceMixin provides both concise helpers (e.g. $contacts, capabilities)
@@ -135,6 +144,7 @@ export default class DataExportSection extends Vue {
beforeUnmount() {
if (this.downloadUrl && this.isWebPlatform) {
URL.revokeObjectURL(this.downloadUrl);
+ this.downloadUrl = "";
}
}
@@ -183,9 +193,31 @@ export default class DataExportSection extends Vue {
*/
private async handleWebExport(blob: Blob): Promise {
this.downloadUrl = URL.createObjectURL(blob);
- const downloadAnchor = this.$refs.downloadLink as HTMLAnchorElement;
- downloadAnchor.click();
- setTimeout(() => URL.revokeObjectURL(this.downloadUrl), 1000);
+
+ try {
+ // Wait for next tick to ensure DOM is updated
+ await this.$nextTick();
+
+ const downloadAnchor = this.$refs.downloadLink as HTMLAnchorElement;
+ if (!downloadAnchor) {
+ throw new Error("Download link element not found. Please try again.");
+ }
+
+ downloadAnchor.click();
+
+ // Clean up the URL after a delay
+ setTimeout(() => {
+ URL.revokeObjectURL(this.downloadUrl);
+ this.downloadUrl = "";
+ }, 1000);
+ } catch (error) {
+ // Clean up the URL on error
+ if (this.downloadUrl) {
+ URL.revokeObjectURL(this.downloadUrl);
+ this.downloadUrl = "";
+ }
+ throw error;
+ }
}
/**