on master help sign in
Simplify dropdown item title finding

(still dumb though)

commit97c5d10541aae2293e16687e166b60d881aaaf97 authorFang <git@fang.io> dateWed 1 May 2019, 19:59 (8 years ago) parent65a1ac4
2 files changed+3−28
src/bridge/views/Ledger.js+2−18 src/bridge/views/Trezor.js+1−10
src/bridge/views/Ledger.js+2−18
@@ -96,15 +96,7 @@ class Ledger extends React.Component {
9696 value: 'custom'
9797 }
9898 ];
99− //NOTE this is dumb
100− let basePathTitle = '';
101− for (let i in pathOptions) {
102− let option = pathOptions[i];
103− if (option.value === basePath) {
104− basePathTitle = option.title;
105− break;
106− }
107− }
99+ let basePathTitle = pathOptions.find(o => (o.value === basePath)).title;
108100
109101 let accountOptions = [];
110102 for (let i = 0; i < 20; i++) {
@@ -113,15 +105,7 @@ class Ledger extends React.Component {
113105 value: i
114106 });
115107 }
116− //NOTE this is dumb
117− let accountTitle = '';
118− for (let i in accountOptions) {
119− let option = accountOptions[i];
120− if (option.value === account) {
121− accountTitle = option.title;
122− break;
123− }
124− }
108+ let accountTitle = accountOptions.find(o => (o.value === account)).title;
125109
126110 const basePathSelection = (
127111 <InnerLabelDropdown
src/bridge/views/Trezor.js+1−10
@@ -65,7 +65,6 @@ class Trezor extends React.Component {
6565 const { pushRoute, popRoute, wallet } = this.props
6666 const { hdpath, account } = this.state
6767 const { handleAccountSelection } = this;
68− console.log('hdpath', hdpath)
6968
7069 let accountOptions = [{
7170 title: 'Custom path',
@@ -77,15 +76,7 @@ class Trezor extends React.Component {
7776 value: i
7877 });
7978 }
80− //NOTE this is dumb
81− let accountTitle = '';
82− for (let i in accountOptions) {
83− let option = accountOptions[i];
84− if (option.value === account) {
85− accountTitle = option.title;
86− break;
87− }
88− }
79+ let accountTitle = accountOptions.find(o => (o.value === account)).title;
8980
9081 const accountSelection = (
9182 <InnerLabelDropdown