Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
lightning-bits
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bitsoko services
lightning-bits
Commits
d8f3340c
Unverified
Commit
d8f3340c
authored
May 09, 2019
by
Valentine Wallace
Committed by
Tankred Hase
May 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Automatically focus first input during restore seed pagination.
parent
f4c5f325
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
2 deletions
+31
-2
wallet.js
src/action/wallet.js
+10
-0
store.js
src/store.js
+1
-0
restore-seed.js
src/view/restore-seed.js
+9
-2
wallet.spec.js
test/unit/action/wallet.spec.js
+11
-0
No files found.
src/action/wallet.js
View file @
d8f3340c
...
...
@@ -56,6 +56,14 @@ class WalletAction {
this
.
_store
.
wallet
.
restoreSeed
[
index
]
=
word
;
}
/**
* Set which seed restore input is in focus.
* @param {number} options.index The index of the input.
*/
setFocusedRestoreInd
({
index
})
{
this
.
_store
.
wallet
.
focusedRestoreInd
=
index
;
}
//
// Wallet Password actions
//
...
...
@@ -327,6 +335,7 @@ class WalletAction {
initNextRestorePage
()
{
if
(
this
.
_store
.
wallet
.
restoreIndex
<
21
)
{
this
.
_store
.
wallet
.
restoreIndex
+=
3
;
this
.
_store
.
wallet
.
focusedRestoreInd
=
this
.
_store
.
wallet
.
restoreIndex
;
}
else
{
this
.
initSetPassword
();
}
...
...
@@ -340,6 +349,7 @@ class WalletAction {
initPrevRestorePage
()
{
if
(
this
.
_store
.
wallet
.
restoreIndex
>=
3
)
{
this
.
_store
.
wallet
.
restoreIndex
-=
3
;
this
.
_store
.
wallet
.
focusedRestoreInd
=
this
.
_store
.
wallet
.
restoreIndex
;
}
else
{
this
.
_nav
.
goSelectSeed
();
}
...
...
src/store.js
View file @
d8f3340c
...
...
@@ -51,6 +51,7 @@ export class Store {
seedVerify
:
[
''
,
''
,
''
],
seedIndex
:
0
,
restoreIndex
:
0
,
focusedRestoreInd
:
0
,
restoreSeed
:
Array
(
24
).
fill
(
''
),
},
transactions
:
[],
...
...
src/view/restore-seed.js
View file @
d8f3340c
...
...
@@ -52,8 +52,15 @@ const RestoreSeedView = ({ store, wallet }) => (
wallet
.
setRestoreSeed
({
word
,
index
:
seedIndex
-
1
})
}
key
=
{
i
}
autoFocus
=
{
i
===
0
}
onSubmitEditing
=
{()
=>
wallet
.
initNextRestorePage
()}
autoFocus
=
{
seedIndex
-
1
===
store
.
wallet
.
focusedRestoreInd
}
onSubmitEditing
=
{()
=>
i
===
2
?
wallet
.
initNextRestorePage
()
:
wallet
.
setFocusedRestoreInd
({
index
:
seedIndex
})
}
onClick
=
{()
=>
wallet
.
setFocusedRestoreInd
({
index
:
seedIndex
-
1
})
}
/
>
))}
<
/Card
>
...
...
test/unit/action/wallet.spec.js
View file @
d8f3340c
...
...
@@ -381,6 +381,13 @@ describe('Action Wallet Unit Tests', () => {
});
});
describe
(
'setFocusedRestoreInd()'
,
()
=>
{
it
(
'should set the currently focused restore seed index'
,
()
=>
{
wallet
.
setFocusedRestoreInd
({
index
:
5
});
expect
(
store
.
wallet
.
focusedRestoreInd
,
'to equal'
,
5
);
});
});
describe
(
'initPrevRestorePage()'
,
()
=>
{
it
(
'should navigate to select seed if restoreIndex < 3'
,
()
=>
{
store
.
wallet
.
restoreIndex
=
2
;
...
...
@@ -391,9 +398,11 @@ describe('Action Wallet Unit Tests', () => {
it
(
'should decrement restoreIndex if greater than 2'
,
async
()
=>
{
store
.
wallet
.
restoreIndex
=
3
;
store
.
wallet
.
focusedRestoreInd
=
5
;
wallet
.
initPrevRestorePage
();
expect
(
nav
.
goSelectSeed
,
'was not called'
);
expect
(
store
.
wallet
.
restoreIndex
,
'to equal'
,
0
);
expect
(
store
.
wallet
.
focusedRestoreInd
,
'to equal'
,
0
);
});
});
...
...
@@ -407,9 +416,11 @@ describe('Action Wallet Unit Tests', () => {
it
(
'should increment restoreIndex if less than 21'
,
async
()
=>
{
store
.
wallet
.
restoreIndex
=
18
;
store
.
wallet
.
focusedRestoreInd
=
19
;
wallet
.
initNextRestorePage
();
expect
(
nav
.
goSetPassword
,
'was not called'
);
expect
(
store
.
wallet
.
restoreIndex
,
'to equal'
,
21
);
expect
(
store
.
wallet
.
focusedRestoreInd
,
'to equal'
,
21
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment