From a2f08c6e1407f4de6cf6656eef8b03d7dc4b008e Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 7 Jan 2020 10:58:46 +1100 Subject: [PATCH] Stylistic icing --- js/views/qr_dialog_view_old.js | 47 -------- ts/components/session/SessionSeedModal.tsx | 133 +++++++++++---------- 2 files changed, 72 insertions(+), 108 deletions(-) delete mode 100644 js/views/qr_dialog_view_old.js diff --git a/js/views/qr_dialog_view_old.js b/js/views/qr_dialog_view_old.js deleted file mode 100644 index c365166c7..000000000 --- a/js/views/qr_dialog_view_old.js +++ /dev/null @@ -1,47 +0,0 @@ -/* global Whisper, i18n, QRCode */ - -// eslint-disable-next-line func-names -(function() { - 'use strict'; - - window.Whisper = window.Whisper || {}; - - Whisper.QRDialogView = Whisper.View.extend({ - templateName: 'qr-code-template', - className: 'loki-dialog qr-dialog modal', - initialize(options = {}) { - this.okText = options.okText || i18n('ok'); - this.render(); - this.$('.qr-dialog').bind('keyup', event => this.onKeyup(event)); - - if (options.string) { - this.qr = new QRCode(this.$('#qr')[0], { - correctLevel: QRCode.CorrectLevel.L, - }).makeCode(options.string); - this.$('#qr').addClass('ready'); - } - }, - events: { - 'click .ok': 'close', - }, - render_attributes() { - return { - ok: this.okText, - }; - }, - close() { - this.remove(); - }, - onKeyup(event) { - switch (event.key) { - case 'Enter': - case 'Escape': - case 'Esc': - this.close(); - break; - default: - break; - } - }, - }); -})(); diff --git a/ts/components/session/SessionSeedModal.tsx b/ts/components/session/SessionSeedModal.tsx index 7ba3350a9..05b4592f6 100644 --- a/ts/components/session/SessionSeedModal.tsx +++ b/ts/components/session/SessionSeedModal.tsx @@ -40,19 +40,83 @@ export class SessionSeedModal extends React.Component { window.addEventListener('keyup', this.onEnter); } - public render() { + private renderPasswordView() { + const maxPasswordLen = 64; + const error = this.state.error; const i18n = window.i18n; const { onClose } = this.props; - const maxPasswordLen = 64; + return ( + <> +

{i18n('showSeedPasswordRequest')}

+ + + {error && ( + <> +
+
{error}
+ + )} + +
+ +
+ + + +
+ + ); + } + + private renderSeedView() { + const i18n = window.i18n; + const { onClose } = this.props; + + return ( + <> +
+

+ {i18n('seedSavePromptMain')} +
+ {i18n('seedSavePromptAlt')} +

+
+ + {this.state.seed} +
+
+ +
+ + + { + this.copySeed(this.state.seed); + }} + /> +
+ + ); + } + + public render() { + const i18n = window.i18n; this.checkHasPassword(); void this.getSeed(); - const error = this.state.error; - const hasPassword = this.state.hasPassword; - const passwordValid = this.state.passwordValid; - + const { onClose } = this.props; + const { hasPassword, passwordValid } = this.state; const loading = this.state.loadingPassword || this.state.loadingSeed; return ( @@ -66,62 +130,9 @@ export class SessionSeedModal extends React.Component {
{hasPassword && !passwordValid ? ( -
-

{i18n('showSeedPasswordRequest')}

- - - {error && ( - <> -
-
{error}
- - )} - -
- -
- - - -
-
+ <>{this.renderPasswordView()} ) : ( - <> -
-

- {i18n('seedSavePromptMain')} -
- - {i18n('seedSavePromptAlt')} - -

-
- - - {this.state.seed} - -
-
- -
- - - { - this.copySeed(this.state.seed); - }} - /> -
- + <>{this.renderSeedView()} )} )}