on master help sign in
chore: minor updates to comments, code re-org
commit6b3335e88a7cd7bc6f4277f0745ab343563886ae authorMatt Condon (shrugs) <mattgcondon@gmail.com> dateWed 31 Jul 2019, 11:41 (7 years ago) parentf231080
3 files changed+14−11
src/indigo-react/components/Input.js+7−7 src/views/Activate/ActivateCode.js+6−2 src/views/Login/Mnemonic.js+1−2
src/indigo-react/components/Input.js+7−7
@@ -54,8 +54,8 @@ export default function Input({
5454
5555 return (
5656 <Flex
57− className={cn(className, 'mb1')}
5857 col
58+ className={cn(className, 'mb1')}
5959 style={{
6060 ...(disabled && {
6161 pointerEvents: 'none',
@@ -71,8 +71,9 @@ export default function Input({
7171 htmlFor={name}>
7272 {label}
7373 </Flex.Item>
74− <Flex.Item as={Flex} className="rel" row>
74+ <Flex.Item as={Flex} row className="rel">
7575 <Flex.Item
76+ flex
7677 as={type === 'textarea' ? 'textarea' : 'input'}
7778 type={type === 'textarea' ? undefined : type}
7879 {...rest}
@@ -86,21 +87,20 @@ export default function Input({
8687 'bg-gray1': disabled,
8788 },
8889 {
89− gray4: !active && !touched,
90+ gray4: !(active || touched),
9091 black: active || touched,
9192 },
9293 {
9394 'b-green3': valid,
94− 'b-black': active && !valid,
95− 'b-yellow3': !active && touched && error,
96− 'b-gray2': !active && !error && !valid,
95+ 'b-black': !valid && active,
96+ 'b-yellow3': !valid && !active && touched && error,
97+ 'b-gray2': !valid && !active && !touched && !error,
9798 }
9899 )}
99100 id={name}
100101 name={name}
101102 onKeyPress={onKeyPress}
102103 {...input}
103− flex
104104 />
105105 {accessory && (
106106 <div
src/views/Activate/ActivateCode.js+6−2
@@ -54,6 +54,9 @@ export default function ActivateCode() {
5454 }
5555 }, [names, push, hasDisclaimed]);
5656
57+ // validate should be a pure function but we don't want to have to recompute
58+ // all of this information on submit, so cache the invite wallet and avoid
59+ // re-renders that may trigger re-validations (causing infinite loop)
5760 const validate = useCallback(
5861 async ticket => {
5962 await timeout(100); // allow the ui changes to flush before we lag it out
@@ -99,6 +102,7 @@ export default function ActivateCode() {
99102 [contracts, setDerivedPoint]
100103 );
101104
105+ // set our state on submission
102106 const onSubmit = useCallback(
103107 async values => {
104108 setInviteWallet(cachedInviteWallet.current);
@@ -112,8 +116,8 @@ export default function ActivateCode() {
112116 return (
113117 <View inset>
114118 <Grid>
115− <Grid.Item as={Passport} point={derivedPoint} full />
116− <Grid.Item as={H4} className="mt3 mb2" full>
119+ <Grid.Item full as={Passport} point={derivedPoint} />
120+ <Grid.Item full as={H4} className="mt3 mb2">
117121 Activate
118122 </Grid.Item>
119123 <BridgeForm
src/views/Login/Mnemonic.js+1−2
@@ -24,7 +24,6 @@ export default function Mnemonic({ className }) {
2424 // when the properties change, re-derive wallet and set global state
2525 const onValues = useCallback(
2626 ({ valid, values }) => {
27− console.log(valid, values);
2827 if (valid) {
2928 setWalletHdPath(values.hdpath);
3029 setAuthMnemonic(Just(values.mnemonic));
@@ -44,7 +43,7 @@ export default function Mnemonic({ className }) {
4443 <BridgeForm
4544 onValues={onValues}
4645 onSubmit={() => undefined}
47− initialValues={{ hdpath: walletHdPath, advanced: false }}>
46+ initialValues={{ hdpath: walletHdPath }}>
4847 {() => (
4948 <>
5049 <Grid.Item