From ed5d87e797d458e2149d914021d36f352c3aa202 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 21 Nov 2018 13:57:31 +0000 Subject: [PATCH] Add recovery key download button --- .../keybackup/CreateKeyBackupDialog.js | 35 +++++++++++++++++-- src/i18n/strings/en_EN.json | 4 ++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js b/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js index aeb0c33b67..9dfcdb1f2b 100644 --- a/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js +++ b/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js @@ -18,6 +18,8 @@ import React from 'react'; import sdk from '../../../../index'; import MatrixClientPeg from '../../../../MatrixClientPeg'; +import FileSaver from 'file-saver'; + import { _t, _td } from '../../../../languageHandler'; const PHASE_PASSPHRASE = 0; @@ -49,6 +51,7 @@ export default React.createClass({ passPhrase: '', passPhraseConfirm: '', copied: false, + downloaded: false, }; }, @@ -72,6 +75,18 @@ export default React.createClass({ } }, + _onDownloadClick: function() { + const blob = new Blob([this._keyBackupInfo.recovery_key], { + type: 'text/plain;charset=us-ascii', + }); + FileSaver.saveAs(blob, 'recovery-key.txt'); + + this.setState({ + downloaded: true, + phase: PHASE_KEEPITSAFE, + }); + }, + _createBackup: function() { this.setState({ phase: PHASE_BACKINGUP, @@ -278,13 +293,21 @@ export default React.createClass({
{_t("Your Recovery Key")}
+ { + // FIXME REDESIGN: buttons should be adjacent but insufficient room in current design + } +

+
{this._keyBackupInfo.recovery_key}

+
copied to your clipboard, paste it to:", + {}, {b: s => {s}}, + ); + } else if (this.state.downloaded) { + introText = _t( + "Your Recovery Key is in your Downloads folder.", + {}, {b: s => {s}}, + ); } const DialogButtons = sdk.getComponent('views.elements.DialogButtons'); return
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index be713bdb37..20618e305e 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -986,8 +986,10 @@ "As a safety net, you can use it to restore your encrypted message history if you forget your Recovery Passphrase.": "As a safety net, you can use it to restore your encrypted message history if you forget your Recovery Passphrase.", "Your Recovery Key": "Your Recovery Key", "Copy to clipboard": "Copy to clipboard", + "Download": "Download", "I've made a copy": "I've made a copy", - "Your Recovery Key has been copied to your clipboard, paste it to:": "Your Recovery Key has been copied to your clipboard, paste it to:", + "Your Recovery Key has been copied to your clipboard, paste it to:": "Your Recovery Key has been copied to your clipboard, paste it to:", + "Your Recovery Key is in your Downloads folder.": "Your Recovery Key is in your Downloads folder.", "Print it and store it somewhere safe": "Print it and store it somewhere safe", "Save it on a USB key or backup drive": "Save it on a USB key or backup drive", "Copy it to your personal cloud storage": "Copy it to your personal cloud storage",