on master help sign in
Update IncomingPoint to show proper layer
ad88110Will Galebach
src/components/L2/Points/IncomingPoint.tsx+12−2
@@ -1,9 +1,10 @@
1−import React from 'react';
1+import React, { useEffect, useState } from 'react';
2import * as ob from 'urbit-ob';
2import * as ob from 'urbit-ob';
3import { Box } from '@tlon/indigo-react';
3import { Box } from '@tlon/indigo-react';
4
4
5import LayerIndicator from '../LayerIndicator';
5import LayerIndicator from '../LayerIndicator';
6import './IncomingPoint.scss';
6import './IncomingPoint.scss';
7+import useRoller from 'lib/useRoller';
7
8
8export interface IncomingPointProps {
9export interface IncomingPointProps {
9 point: number;
10 point: number;
@@ -12,6 +13,15 @@ export interface IncomingPointProps {
12}
13}
13
14
14const IncomingPoint = ({ point, accept, reject }: IncomingPointProps) => {
15const IncomingPoint = ({ point, accept, reject }: IncomingPointProps) => {
16+ const { api } = useRoller();
17+ const [layer, setLayer] = useState<1 | 2>(1);
18+
19+ useEffect(() => {
20+ api.getPoint(point).then(p => {
21+ setLayer(p.dominion === 'l2' ? 2 : 1);
22+ });
23+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
24+
15 return (
25 return (
16 <Box className="incoming-point" key={`incoming-${point}`}>
26 <Box className="incoming-point" key={`incoming-${point}`}>
17 <Box className="top">
27 <Box className="top">
@@ -26,7 +36,7 @@ const IncomingPoint = ({ point, accept, reject }: IncomingPointProps) => {
26 </Box>
36 </Box>
27 </Box>
37 </Box>
28 <Box className="bottom">
38 <Box className="bottom">
29− <LayerIndicator layer={1} size="sm" />
39+ <LayerIndicator layer={layer} size="sm" />
30 <Box className="date"></Box>
40 <Box className="date"></Box>
31 </Box>
41 </Box>
32 </Box>
42 </Box>
src/lib/useRoller.ts+1−4
@@ -403,8 +403,6 @@ export default function useRoller() {
403 getDetails
403 getDetails
404 ).filter((p: number) => isPlanet(p) && availablePoints.includes(p));
404 ).filter((p: number) => isPlanet(p) && availablePoints.includes(p));
405
405
406− console.log(pendingSpawns, outgoingPoints, invitePoints)
407−
408 setPendingTransactions(newPending);
406 setPendingTransactions(newPending);
409 setInvitePoints(
407 setInvitePoints(
410 invitePoints
408 invitePoints
@@ -448,8 +446,7 @@ export default function useRoller() {
448 throw new Error('Internal Error: Missing Wallet/Details');
446 throw new Error('Internal Error: Missing Wallet/Details');
449 }
447 }
450
448
451− const pointDetails = await api.getPoint(_point);
452− const proxy = getManagerProxy(pointDetails.ownership!, _wallet.address);
449+ const proxy = getManagerProxy(azimuthPoint.ownership!, _wallet.address);
453
450
454 if (proxy === undefined)
451 if (proxy === undefined)
455 throw new Error("Error: Address doesn't match proxy");
452 throw new Error("Error: Address doesn't match proxy");