import React, { useCallback } from 'react'; import { Grid } from 'indigo-react'; import cn from 'classnames'; import * as ob from 'urbit-ob'; import Sigil from 'components/Sigil'; import { usePointCache } from 'store/pointCache'; import { useWallet } from 'store/wallet'; import * as need from 'lib/need'; import usePermissionsForPoint from 'lib/usePermissionsForPoint'; import { useSyncOwnedPoints } from 'lib/useSyncPoints'; import { buildKeyType } from 'lib/point'; function ActiveViewRow({ point, goPoint }) { const { wallet } = useWallet(); const address = need.addressFromWallet(wallet); useSyncOwnedPoints([point]); const permissions = usePermissionsForPoint(address, point); const keyType = buildKeyType(permissions); const patp = ob.patp(point); const sigilSize = 50; const onClick = useCallback(() => goPoint(point), [point, goPoint]); return ( <> {patp}{' '}
{keyType} -> ); } export default function ActiveView({ className, goPoint }) { // const points = [2560, 2561, 2562]; const { controlledPoints } = usePointCache(); console.log(controlledPoints); const points = controlledPoints .matchWith({ Nothing: () => [], Just: ps => ps.value.matchWith({ Error: () => null, Ok: ({ value }) => { return [ ...value.ownedPoints, ...value.votingPoints, ...value.managingPoints, ...value.spawningPoints, ]; }, }), }) .filter(Boolean) .filter(p => 255 < p && p < 65536); return ( Point Key Type {points.length === 0 && ( You have no active stars )} {points.map(point => ( ))} ); }