@@ -1,143 +1,62 @@
1−import { Just, Nothing } from 'folktale/maybe';
1+import React, { useCallback } from 'react';
2−import React from 'react';
3−import { pour } from 'sigil-js';
4−import * as ob from 'urbit-ob';
5−import * as azimuth from 'azimuth-js';
6−import * as need from '../lib/need';
2+import * as need from 'lib/need';
8−import PointList from '../components/old/PointList';
4+import { usePointCursor } from 'store/pointCursor';
9−import ReactSVGComponents from '../components/ReactSVGComponents';
5+// import { usePointCache } from 'store/pointCache';
10−import KeysAndMetadata from './Point/KeysAndMetadata';
11−import Actions from './Point/Actions';
12−import { H1, H3 } from '../components/old/Base';
13−import { withHistory } from '../store/history';
14−import { withNetwork } from '../store/network';
15−import { compose } from '../lib/lib';
16−import { withWallet } from '../store/wallet';
17−import { withPointCursor } from '../store/pointCursor';
18−import { withPointCache } from '../store/pointCache';
19−import View from 'components/View';
21−class Point extends React.Component {
31− componentDidMount() {
35− componentDidUpdate(prevProps) {
39− // When a link in the 'issued points' component is clicked, we don't
40− // actually leave the Point component, and componentDidMount will not fire
41− // again. But, we can force a call to cachePoints here.
43− const oldCursor = prevProps.pointCursor.getOrElse(true);
44− const newCursor = this.props.pointCursor.getOrElse(true);
46− if (oldCursor !== newCursor) {
52− const { web3, contracts, pointCursor, addToPointCache } = this.props;
55− contracts.chain(ctrcs =>
56− pointCursor.chain(point => {
58− .getPoint(ctrcs, point)
59− .then(details => addToPointCache({ [point]: details }));
60− azimuth.delegatedSending
61− .getTotalUsableInvites(ctrcs, point)
62− .then(count => this.setState({ invites: Just(count) }));
63− this.updateSpawned(ctrcs, point);
69− updateSpawned = contracts => {
70− const { pointCursor } = this.props;
72− pointCursor.matchWith({
76− .getSpawned(contracts, point.value)
77− .then(spawned => this.setState({ spawned }));
83− const { web3, history, wallet, pointCache } = this.props;
85− const { spawned } = this.state;
87− const point = need.pointCursor(this.props.pointCursor);
7+import View from 'components/View';
88−
8+import useInvites from 'lib/useInvites';
89− const pointDetails =
9+import useSyncPoint from 'lib/useSyncPoint';
90− point in pointCache ? Just(pointCache[point]) : Nothing();
10+import Passport from 'components/Passport';
91−
11+import { Grid } from 'indigo-react';
92− const name = ob.patp(point);
12+import { ForwardButton } from 'components/Buttons';
93−
13+import { useHistory } from 'store/history';
94− const sigil = pour({
14+import { ROUTE_NAMES } from 'lib/routeNames';
95− patp: name,
15+import Footer from 'components/Footer';
96− renderer: ReactSVGComponents,
16+
97− size: 256,
17+export default function Point() {
98− });
18+ const history = useHistory();
99−
19+ const { pointCursor } = usePointCursor();
100− const online = Just.hasInstance(web3);
20+ // const { pointCache } = usePointCache();
102− const authenticated = Just.hasInstance(wallet);
22+ const point = need.pointCursor(pointCursor);
104− const issuedPointList =
24+ // fetch the invites for the current cursor
105− spawned.length === 0 ? (
25+ const { invites } = useInvites(point);
107− ) : (
27+ const goAdmin = useCallback(() => {}, []);
108− <div>
28+ // ^ TODO: push .ADMIN
109− <H3>{'Issued Points'}</H3>
29+ const goInvite = useCallback(() => history.push(ROUTE_NAMES.INVITES_MANAGE), [
111− <PointList routeHandler={history.popAndPush} points={spawned} />
31+ ]);
113− );
33+ // sync the current cursor
114−
34+ useSyncPoint(point);
36+ // const pointDetails = need.fromPointCache(pointCache, point);
115− return (
38+ return (
117− <div className={'mt-12 pt-6'}>{sigil}</div>
40+ <Passport point={point} />
118− <H1>
41+ <Grid className="pt2">
119− <code>{name}</code>
42+ <Grid.Item full>
120− </H1>
43+ <ForwardButton onClick={goAdmin}>Admin</ForwardButton>
121− {authenticated ? (
44+ </Grid.Item>
122− <Actions
45+ <Grid.Divider />
123− online={online}
46+ <Grid.Item full>
124− point={point}
47+ <ForwardButton detail="Boot your computer" disabled>
125− pointDetails={pointDetails}
48+ Boot Arvo
126− invites={this.state.invites}
49+ </ForwardButton>
128− ) : null}
51+ </Grid>
130− {online ? <KeysAndMetadata pointDetails={pointDetails} /> : <div />}
53+ <Grid className="pt2">
131− {issuedPointList}
54+ <Grid.Divider />
132− </View>
55+ <Grid.Item full>
133− );
56+ <ForwardButton onClick={goInvite}>Invite</ForwardButton>
137−export default compose(