on master help sign in
fix: clean up keyfile button notice
commit6ecd461509b798b7078d74c33965e3c667e46567 authorMatt Condon (shrugs) <mattgcondon@gmail.com> dateThu 18 Jul 2019, 13:22 (7 years ago) parent072c6eb
2 files changed+17−16
src/components/DownloadKeyfileButton.js+2−8 src/lib/useKeyfileGenerator.js+15−8
src/components/DownloadKeyfileButton.js+2−8
@@ -9,25 +9,19 @@ export default function DownloadKeyfileButton({
99 available,
1010 downloaded,
1111 download,
12+ notice,
1213
1314 // from caller
1415 className,
1516 ...rest
1617}) {
17− const showHelp = !generating && !available;
18−
1918 return (
2019 <DownloadButton
2120 as="span"
2221 className={className}
2322 disabled={downloaded || !available}
2423 disabledDetail={
25− showHelp && (
26− <B className="wrap ws-normal">
27− · Custom or nondeterministic networking keys cannot be
28− re-downloaded.
29− </B>
30− )
24+ !available && <B className="wrap ws-normal">· {notice}</B>
3125 }
3226 loading={generating}
3327 onClick={download}
src/lib/useKeyfileGenerator.js+15−8
@@ -18,10 +18,11 @@ import {
1818import useCurrentPermissions from './useCurrentPermissions';
1919
2020export default function useKeyfileGenerator(manualNetworkSeed) {
21− const { getDetails } = usePointCache();
2221 const { urbitWallet, wallet, authMnemonic } = useWallet();
2322 const { pointCursor } = usePointCursor();
23+ const { getDetails } = usePointCache();
2424
25+ const [notice, setNotice] = useState('Deriving networking keys...');
2526 const [downloaded, setDownloaded] = useState(false);
2627 const [generating, setGenerating] = useState(true);
2728 const [keyfile, setKeyfile] = useState(false);
@@ -36,12 +37,13 @@ export default function useKeyfileGenerator(manualNetworkSeed) {
3637 const available =
3738 (isOwner || isManagementProxy) && hasNetworkingKeys && !!keyfile;
3839
39− console.log(
40− `keyfile available (${available}) for revision ${networkRevision}`
41− );
42−
4340 const generate = useCallback(async () => {
44− console.log('generating for network revision', networkRevision);
41+ console.log('attempting generation for network revision', networkRevision);
42+ if (!hasNetworkingKeys) {
43+ setGenerating(false);
44+ setNotice('Networking keys not yet set.');
45+ return;
46+ }
4547
4648 const networkSeed = manualNetworkSeed
4749 ? Just(manualNetworkSeed)
@@ -55,7 +57,9 @@ export default function useKeyfileGenerator(manualNetworkSeed) {
5557
5658 if (Nothing.hasInstance(networkSeed)) {
5759 setGenerating(false);
58− console.log('manual network seed not provided and key not derivable');
60+ setNotice(
61+ 'Custom or nondeterministic networking keys cannot be re-downloaded.'
62+ );
5963 return;
6064 }
6165
@@ -65,14 +69,16 @@ export default function useKeyfileGenerator(manualNetworkSeed) {
6569
6670 if (!keysMatchChain(pair, _details)) {
6771 setGenerating(false);
68− console.log('derived network keys do not match on-chain details');
72+ setNotice('Derived networking keys do not match on-chain details.');
6973 return;
7074 }
7175
76+ setNotice();
7277 setKeyfile(compileNetworkingKey(pair, _point, networkRevision));
7378 setGenerating(false);
7479 }, [
7580 networkRevision,
81+ hasNetworkingKeys,
7682 manualNetworkSeed,
7783 urbitWallet,
7884 wallet,
@@ -101,6 +107,7 @@ export default function useKeyfileGenerator(manualNetworkSeed) {
101107 available,
102108 downloaded,
103109 download,
110+ notice,
104111 };
105112
106113 return { ...values, bind: values };