on master help sign in
ux: show network keys modal when unset
441cb95tomholford
src/components/L2/Dropdowns/AccountsDropdown.tsx+2−2
@@ -36,7 +36,7 @@ const AccountsDropdown = ({ showMigrate = false }: AccountsDropdownProps) => {
36 const { currentL2 }: any = useRollerStore();
36 const { currentL2 }: any = useRollerStore();
37
37
38 const networkKeysSet = useHasNetworkKeysSet();
38 const networkKeysSet = useHasNetworkKeysSet();
39− const showMigrateModal = useMemo(() => {
39+ const showMigrateOption = useMemo(() => {
40 return showMigrate || (!currentL2 && networkKeysSet);
40 return showMigrate || (!currentL2 && networkKeysSet);
41 }, [currentL2, networkKeysSet, showMigrate]);
41 }, [currentL2, networkKeysSet, showMigrate]);
42
42
@@ -106,7 +106,7 @@ const AccountsDropdown = ({ showMigrate = false }: AccountsDropdownProps) => {
106 })}
106 })}
107 </Box>
107 </Box>
108 <Box className="divider" />
108 <Box className="divider" />
109− {showMigrateModal && (
109+ {showMigrateOption && (
110 <Row className="entry" onClick={() => setShowModal(true)}>
110 <Row className="entry" onClick={() => setShowModal(true)}>
111 <Box>Migrate</Box>
111 <Box>Migrate</Box>
112 <Row className="layer-migration">
112 <Row className="layer-migration">
src/lib/useHasNetworkKeysSet.tsx+2−8
@@ -2,27 +2,21 @@ import { useEffect, useMemo, useState } from 'react';
2import * as need from 'lib/need';
2import * as need from 'lib/need';
3import { usePointCache } from 'store/pointCache';
3import { usePointCache } from 'store/pointCache';
4import { usePointCursor } from 'store/pointCursor';
4import { usePointCursor } from 'store/pointCursor';
5−import { useRollerStore } from 'store/roller';
6import { convertToInt } from 'lib/convertToInt';
5import { convertToInt } from 'lib/convertToInt';
7−import { isPlanet } from 'lib/utils/point';
8
6
9export const useHasNetworkKeysSet = () => {
7export const useHasNetworkKeysSet = () => {
10 const { pointCursor } = usePointCursor();
8 const { pointCursor } = usePointCursor();
11 const { getDetails } = usePointCache();
9 const { getDetails } = usePointCache();
12− const { currentL2 } = useRollerStore();
13 const point = pointCursor.getOrElse(null);
10 const point = pointCursor.getOrElse(null);
14 const [networkKeysSet, setNetworkKeysSet] = useState<boolean>(true);
11 const [networkKeysSet, setNetworkKeysSet] = useState<boolean>(true);
15
12
16 useEffect(() => {
13 useEffect(() => {
17 if (point) {
14 if (point) {
18 const details = need.details(getDetails(point));
15 const details = need.details(getDetails(point));
19− const isStarOrGalaxy = !isPlanet(point);
20 const networkRevision = convertToInt(details.keyRevisionNumber, 10);
16 const networkRevision = convertToInt(details.keyRevisionNumber, 10);
21− const networkKeysNotSet =
22− !currentL2 && isStarOrGalaxy && networkRevision === 0;
23− setNetworkKeysSet(!networkKeysNotSet);
17+ setNetworkKeysSet(networkRevision > 0);
24 }
18 }
25− }, [currentL2, getDetails, point, pointCursor]);
19+ }, [getDetails, point, pointCursor]);
26
20
27 return useMemo(() => {
21 return useMemo(() => {
28 return networkKeysSet;
22 return networkKeysSet;
src/views/Point/Point.tsx+5−1
@@ -48,7 +48,11 @@ export default function Point() {
48 increaseNonce,
48 increaseNonce,
49 } = useRollerStore();
49 } = useRollerStore();
50 const networkKeysSet = useHasNetworkKeysSet();
50 const networkKeysSet = useHasNetworkKeysSet();
51− const [showModal, setShowModal] = useState(!networkKeysSet);
51+ const [showModal, setShowModal] = useState(false);
52+
53+ useEffect(() => {
54+ setShowModal(!networkKeysSet);
55+ }, [networkKeysSet]);
52
56
53 const loadL1Info = useCallback(async () => {
57 const loadL1Info = useCallback(async () => {
54 await syncExtras(point);
58 await syncExtras(point);