From 85df0e89921396aa9058712288bc9aab06ab0ad0 Mon Sep 17 00:00:00 2001 From: reyraa Date: Thu, 28 Sep 2017 16:59:54 +0200 Subject: [PATCH 1/4] Fix the step calculation --- src/utils/passphrase.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/passphrase.js b/src/utils/passphrase.js index 25ac2d4af..7defa0c94 100644 --- a/src/utils/passphrase.js +++ b/src/utils/passphrase.js @@ -30,7 +30,7 @@ const leftPadd = (str, pad, length) => { * Resets previous settings and creates a step with a random length between 1.6% to 3.2% */ const init = (rand = Math.random()) => { - let step = Math.max((160 + Math.floor(rand * 160))); + let step = (160 + Math.floor(rand * 160)) / 100; step = step >= 0.01 ? step : step * 10; return { step, From 765b76203054c27d7554f9c5b018072e174676e2 Mon Sep 17 00:00:00 2001 From: reyraa Date: Thu, 28 Sep 2017 17:07:40 +0200 Subject: [PATCH 2/4] Fix the step calculation --- src/utils/passphrase.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/passphrase.js b/src/utils/passphrase.js index 25ac2d4af..62f6cd190 100644 --- a/src/utils/passphrase.js +++ b/src/utils/passphrase.js @@ -30,8 +30,8 @@ const leftPadd = (str, pad, length) => { * Resets previous settings and creates a step with a random length between 1.6% to 3.2% */ const init = (rand = Math.random()) => { - let step = Math.max((160 + Math.floor(rand * 160))); - step = step >= 0.01 ? step : step * 10; + let step = (160 + Math.floor(rand * 160)) / 100; + step = step >= 0.01 ? step : 0.1 + (step * 5); return { step, percentage: 0, From f86fcfac4d02c6d60aaf01a8868da358b90f370d Mon Sep 17 00:00:00 2001 From: reyraa Date: Thu, 28 Sep 2017 18:17:36 +0200 Subject: [PATCH 3/4] Fixed the issue with showing the missing word --- src/components/passphrase/passphraseVerifier.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/passphrase/passphraseVerifier.js b/src/components/passphrase/passphraseVerifier.js index e097f53f4..f503d574d 100644 --- a/src/components/passphrase/passphraseVerifier.js +++ b/src/components/passphrase/passphraseVerifier.js @@ -19,11 +19,11 @@ class PassphraseConfirmator extends React.Component { } hideRandomWord(rand = Math.random()) { - const words = this.props.passphrase.trim().split(/\s+/); + const words = this.props.passphrase.trim().split(/\s+/).filter(item => item.length > 0); const index = Math.floor(rand * (words.length - 1)); this.setState({ - passphraseParts: this.props.passphrase.split(` ${words[index]} `), + passphraseParts: this.props.passphrase.split(words[index]), missing: words[index], answer: '', }); From 0b9df247defd52f1bdc66cbb4074ac62cb2afcf1 Mon Sep 17 00:00:00 2001 From: reyraa Date: Thu, 28 Sep 2017 18:38:23 +0200 Subject: [PATCH 4/4] Fix unit tests --- src/components/passphrase/passphraseVerifier.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/passphrase/passphraseVerifier.test.js b/src/components/passphrase/passphraseVerifier.test.js index 6f851a6b4..a5db0cf61 100644 --- a/src/components/passphrase/passphraseVerifier.test.js +++ b/src/components/passphrase/passphraseVerifier.test.js @@ -41,8 +41,8 @@ describe('PassphraseVerifier', () => { const randomIndex = 0.6; const expectedValues = { passphraseParts: [ - 'survey stereo pool fortune oblige slight', - 'goddess mistake sentence anchor pool', + 'survey stereo pool fortune oblige slight ', + ' goddess mistake sentence anchor pool', ], missing: 'gravity', answer: '',