on master help sign in
Simplify dropdown item title finding
97c5d10Fang
src/bridge/views/Ledger.js+2−18
@@ -96,15 +96,7 @@ class Ledger extends React.Component {
96 value: 'custom'
96 value: 'custom'
97 }
97 }
98 ];
98 ];
99− //NOTE this is dumb
100− let basePathTitle = '';
99+ let basePathTitle = pathOptions.find(o => (o.value === basePath)).title;
101− for (let i in pathOptions) {
102− let option = pathOptions[i];
103− if (option.value === basePath) {
104− basePathTitle = option.title;
105− break;
106− }
107− }
108
100
109 let accountOptions = [];
101 let accountOptions = [];
110 for (let i = 0; i < 20; i++) {
102 for (let i = 0; i < 20; i++) {
@@ -113,15 +105,7 @@ class Ledger extends React.Component {
113 value: i
105 value: i
114 });
106 });
115 }
107 }
116− //NOTE this is dumb
117− let accountTitle = '';
108+ let accountTitle = accountOptions.find(o => (o.value === account)).title;
118− for (let i in accountOptions) {
119− let option = accountOptions[i];
120− if (option.value === account) {
121− accountTitle = option.title;
122− break;
123− }
124− }
125
109
126 const basePathSelection = (
110 const basePathSelection = (
127 <InnerLabelDropdown
111 <InnerLabelDropdown
src/bridge/views/Trezor.js+1−10
@@ -65,7 +65,6 @@ class Trezor extends React.Component {
65 const { pushRoute, popRoute, wallet } = this.props
65 const { pushRoute, popRoute, wallet } = this.props
66 const { hdpath, account } = this.state
66 const { hdpath, account } = this.state
67 const { handleAccountSelection } = this;
67 const { handleAccountSelection } = this;
68− console.log('hdpath', hdpath)
69
68
70 let accountOptions = [{
69 let accountOptions = [{
71 title: 'Custom path',
70 title: 'Custom path',
@@ -77,15 +76,7 @@ class Trezor extends React.Component {
77 value: i
76 value: i
78 });
77 });
79 }
78 }
80− //NOTE this is dumb
81− let accountTitle = '';
79+ let accountTitle = accountOptions.find(o => (o.value === account)).title;
82− for (let i in accountOptions) {
83− let option = accountOptions[i];
84− if (option.value === account) {
85− accountTitle = option.title;
86− break;
87− }
88− }
89
80
90 const accountSelection = (
81 const accountSelection = (
91 <InnerLabelDropdown
82 <InnerLabelDropdown