Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add mnemonic copy button #408

Merged
merged 3 commits into from
Apr 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/components/SecretBackupPhraseDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@
<v-icon>mdi-close</v-icon>
</v-btn>
</v-app-bar>
<v-card-text class="pb-0 text-subtitle-1 text-center">
<v-card-text class="pb-0 text-subtitle-1">
<MnemonicKeypad
class="text-center"
:mnemonicCollection="mnemonicCollection"
></MnemonicKeypad>
<p class="pl-5 pr-5">
<p class="pl-5 pr-5 text-center">
<b>Write down these words in the right order and save them safely</b>
</p>
<p class="mt-10 primary--text" role="button" @click="handleCopyMnemonic">
<v-icon class="primary--text">mdi-content-copy</v-icon> {{ copyText }}
</p>
</v-card-text>
<v-card-actions class="px-6 pb-4">
<v-btn
Expand All @@ -45,6 +49,8 @@ import MnemonicKeypad from "./MnemonicKeypad.vue"
import localStorage from "@/lib/local-storage"
const { /*cryptoWaitReady,*/ mnemonicGenerate } = require("@polkadot/util-crypto")

let timeout = 0

export default {
components: { MnemonicKeypad },
name: "SecretBackupPhraseDialog",
Expand All @@ -54,6 +60,7 @@ export default {
},
data: () => ({
mnemonic: "",
copyText: "Copy this Mnemonic Phrase to clipboard",
mnemonicCollection: []
}),
computed: {
Expand Down Expand Up @@ -92,6 +99,15 @@ export default {
const hasAddress = localStorage.getLocalStorageByName("mnemonic_data")

if (!hasAddress) localStorage.removeLocalStorageByName("TERMS")
},
async handleCopyMnemonic() {
await navigator.clipboard.writeText(this.mnemonic)
this.copyText = "Mnemonic has been copied successfully !"

clearTimeout(timeout)
timeout = setTimeout(() => {
this.copyText = "Copy this Mnemonic Phrase to clipboard"
}, 1000)
}
}
}
Expand Down