1import React, { useCallback, useEffect, useState } from 'react';
2import cn from 'classnames';
3import { Just } from 'folktale/maybe';
4import { Grid, Flex, Button } from 'indigo-react';
5import { azimuth } from 'azimuth-js';
6import * as ob from 'urbit-ob';
8import { usePointCursor } from 'store/pointCursor';
9import { useWallet } from 'store/wallet';
11import View from 'components/View';
12import Greeting from 'components/Greeting';
13import Passport from 'components/Passport';
14import Blinky, { matchBlinky } from 'components/Blinky';
15import BarGraph from 'components/BarGraph';
16import Chip from 'components/Chip';
17import InviteSigilList from 'components/InviteSigilList';
18import { ForwardButton } from 'components/Buttons';
20import * as need from 'lib/need';
21import useInvites from 'lib/useInvites';
22import { useSyncExtras } from 'lib/useSyncPoints';
23import useCurrentPermissions from 'lib/useCurrentPermissions';
24import { useLocalRouter } from 'lib/LocalRouter';
26import Inviter from 'views/Invite/Inviter';
27import { usePointCache } from 'store/pointCache';
28import Card from 'components/L2/Card';
29import { Icon, Row } from '@tlon/indigo-react';
30import L2PointHeader from 'components/L2/Headers/L2PointHeader';
31import useRoller from 'lib/useRoller';
32import { useRollerStore } from 'store/roller';
33import LayerIndicator from 'components/L2/LayerIndicator';
34import { convertToInt } from 'lib/convertToInt';
50 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
51 const _pendingInvites = pendingPoints.getOrElse([]).length;
55 <Grid.Item cols={[1, 11]}>
61 className={cn('t-right underline pointer-hover', {
62 gray4: sentInvites.getOrElse(0) === 0,
71 {acceptedInvites.getOrElse(0)} / {_totalInvites}
73 {_pendingInvites > 0 && (
74 <Flex.Item as={Chip} className="bg-yellow1 yellow4">
75 {_pendingInvites} pending
86 available={availableInvites}
88 accepted={acceptedInvites}
93 pendingPoints={pendingPoints}
94 acceptedPoints={acceptedPoints}
100 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
101 <div className="p4 pv8 t-center gray4">
102 Start your invite group by adding members
107 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
113 onClick={() => setShowInviteForm(true)}>
117 {showInviteForm && <Inviter />}
118 <Grid.Item full className="mb2" />
123export default function Point() {
124 const { pop, push, names } = useLocalRouter();
125 const { pointCursor } = usePointCursor();
127 const { wallet, urbitWallet } = useWallet();
128 const point = need.point(pointCursor);
130 const { getResidents } = usePointCache();
131 const { api } = useRoller();
134 setPendingTransactions,
137 } = useRollerStore();
140 console.log('POINT', point);
141 const getTransactions = async () => {
142 const newPending = await api.getPendingByShip(Number(point));
143 console.log('PENDING', newPending);
144 setPendingTransactions(newPending);
146 // get list of spawned planets, and then determine if they have been claimed
147 const allSpawned = await api.getSpawned(Number(point));
148 console.log('SPAWNED', allSpawned.length, allSpawned);
150 const pointInfo = await api.getPoint(Number(point));
151 setCurrentPoint(pointInfo);
152 console.log('POINT', pointInfo);
154 const ownerAddress = pointInfo?.ownership?.owner?.address;
155 console.log('ADDRESS', ownerAddress);
157 const transactionHistory = await api.getHistory(ownerAddress);
158 console.log('TRANSACTION HISTORY', transactionHistory);
163 }, [api, point]); // eslint-disable-line
165 const { residentCount, requestCount } = getResidents(point);
173 } = useCurrentPermissions();
175 const canBitcoin = Just.hasInstance(urbitWallet);
177 // fetch the invites for the current cursor
178 const invites = useInvites(point);
187 const showInvites = !(
188 acceptedInvites.getOrElse(0) === 0 && sentInvites.getOrElse(0) === 0
191 const hasInvites = showInvites || availableInvites.getOrElse(0) !== 0;
193 const loadedInvites = Just.hasInstance(availableInvites);
195 // availableInvites.getOrElse(0) === 0
197 const goSenate = useCallback(() => push(names.SENATE), [push, names]);
199 const goCohort = useCallback(() => push(names.INVITE_COHORT), [push, names]);
201 const goUrbitOS = useCallback(() => push(names.URBIT_OS), [push, names]);
203 const goBitcoin = useCallback(() => push(names.BITCOIN), [push, names]);
205 const goUrbitID = useCallback(() => push(names.URBIT_ID), [push, names]);
207 const goResidents = useCallback(() => push(names.RESIDENTS), [push, names]);
209 const goPartiesSetPoolSize = useCallback(
210 () => push(names.PARTY_SET_POOL_SIZE),
214 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
219 const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
221 const [showInviteForm, setShowInviteForm] = useState(false);
223 const inviteButton = (() => {
224 if (azimuth.getPointSize(point) === azimuth.PointSize.Star) {
230 disabled={!isActiveOwner}
231 onClick={goPartiesSetPoolSize}>
242 const senateButton = (() => {
243 if (azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy) {
260 // sync the current cursor
261 useSyncExtras([point]);
263 const address = need.addressFromWallet(wallet);
265 const _requestCount = requestCount.getOrElse(0);
266 const numPending = pendingTransactions.length;
273 header={<L2PointHeader hideTimer={!!numPending} />}>
274 <Greeting point={point} />
276 <div className="transaction">
277 <Row className="title-row">
278 <div className="title">
279 {numPending} Planet{numPending > 1 ? 's' : ''} Spawned
281 <div className="rollup-timer">{nextRoll}</div>
283 <Row className="info-row">
284 <LayerIndicator layer={2} size="sm" />
285 <div className="date"></div>
291 address={Just(address)}
292 animationMode={'slide'}
296 <Grid.Item full as={Flex} justify="between">
299 subtitle="Manage peers that you service"
300 onClick={goResidents}
304 {isPlanet && hasInvites && (
306 showInviteForm={showInviteForm}
307 setShowInviteForm={setShowInviteForm}
308 acceptedInvites={acceptedInvites}
309 acceptedPoints={acceptedPoints}
310 availableInvites={availableInvites}
312 pendingPoints={pendingPoints}
313 sentInvites={sentInvites}
314 showInvites={showInvites}
317 {!loadedInvites && isPlanet && (
318 <Grid.Item className="mv2" full>
319 Invite Group <Blinky />
322 {/* {inviteButton} */}
323 <Grid.Item full as={Flex} justify="between">
326 subtitle="Identity and security settings"
327 icon={<Icon icon="User" />}
329 disabled={!canManage}
332 <Grid.Item full as={Flex} justify="between">
335 subtitle="Urbit OS Settings"
336 icon={<Icon icon="Server" />}
338 disabled={!canManage}
344 disabled={!canBitcoin}
346 detail="Bitcoin management"
356 onClick={goIssuePoint}>
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list