make a backup download for browsers that don't get it automatically
This commit is contained in:
@@ -162,7 +162,9 @@
|
|||||||
>
|
>
|
||||||
Backup Identifier Seed
|
Backup Identifier Seed
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
|
v-bind:class="computedStartDownloadLinkClassNames()"
|
||||||
class="block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mb-6"
|
class="block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mb-6"
|
||||||
@click="exportDatabase()"
|
@click="exportDatabase()"
|
||||||
>
|
>
|
||||||
@@ -170,7 +172,13 @@
|
|||||||
<br />
|
<br />
|
||||||
(excluding Identifier Data)
|
(excluding Identifier Data)
|
||||||
</a>
|
</a>
|
||||||
<a ref="downloadLink" />
|
<a
|
||||||
|
ref="downloadLink"
|
||||||
|
v-bind:class="computedDownloadLinkClassNames()"
|
||||||
|
class="block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mb-6"
|
||||||
|
>
|
||||||
|
If no download happened yet, click again here to download now.
|
||||||
|
</a>
|
||||||
|
|
||||||
<div v-if="activeDid" class="flex py-2">
|
<div v-if="activeDid" class="flex py-2">
|
||||||
<button class="text-center text-md text-blue-500" @click="checkLimits()">
|
<button class="text-center text-md text-blue-500" @click="checkLimits()">
|
||||||
@@ -438,6 +446,7 @@ export default class AccountViewView extends Vue {
|
|||||||
apiServer = "";
|
apiServer = "";
|
||||||
apiServerInput = "";
|
apiServerInput = "";
|
||||||
derivationPath = "";
|
derivationPath = "";
|
||||||
|
downloadUrl = ""; // because DuckDuckGo doesn't download on automated call to "click" on the anchor
|
||||||
givenName = "";
|
givenName = "";
|
||||||
isRegistered = false;
|
isRegistered = false;
|
||||||
numAccounts = 0;
|
numAccounts = 0;
|
||||||
@@ -580,6 +589,12 @@ export default class AccountViewView extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beforeUnmount() {
|
||||||
|
if (this.downloadUrl) {
|
||||||
|
URL.revokeObjectURL(this.downloadUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes component state with values from the database or defaults.
|
* Initializes component state with values from the database or defaults.
|
||||||
* @param {SettingsType} settings - Object containing settings from the database.
|
* @param {SettingsType} settings - Object containing settings from the database.
|
||||||
@@ -681,13 +696,13 @@ export default class AccountViewView extends Vue {
|
|||||||
const blob = await this.generateDatabaseBlob();
|
const blob = await this.generateDatabaseBlob();
|
||||||
|
|
||||||
// Create a temporary URL for the blob
|
// Create a temporary URL for the blob
|
||||||
const url = this.createBlobURL(blob);
|
this.downloadUrl = this.createBlobURL(blob);
|
||||||
|
|
||||||
// Trigger the download
|
// Trigger the download
|
||||||
this.downloadDatabaseBackup(url);
|
this.downloadDatabaseBackup(this.downloadUrl);
|
||||||
|
|
||||||
// Revoke the temporary URL
|
// Revoke the temporary URL -- not yet because of DuckDuckGo download failure
|
||||||
URL.revokeObjectURL(url);
|
//URL.revokeObjectURL(this.downloadUrl);
|
||||||
|
|
||||||
// Notify the user that the download has started
|
// Notify the user that the download has started
|
||||||
this.notifyDownloadStarted();
|
this.notifyDownloadStarted();
|
||||||
@@ -724,7 +739,19 @@ export default class AccountViewView extends Vue {
|
|||||||
const downloadAnchor = this.$refs.downloadLink as HTMLAnchorElement;
|
const downloadAnchor = this.$refs.downloadLink as HTMLAnchorElement;
|
||||||
downloadAnchor.href = url;
|
downloadAnchor.href = url;
|
||||||
downloadAnchor.download = `${db.name}-backup.json`;
|
downloadAnchor.download = `${db.name}-backup.json`;
|
||||||
downloadAnchor.click();
|
downloadAnchor.click(); // doesn't work for some browsers, eg. DuckDuckGo
|
||||||
|
}
|
||||||
|
|
||||||
|
public computedStartDownloadLinkClassNames() {
|
||||||
|
return {
|
||||||
|
invisible: this.downloadUrl,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public computedDownloadLinkClassNames() {
|
||||||
|
return {
|
||||||
|
invisible: !this.downloadUrl,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user