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';
7import * as wg from 'lib/walletgen';
9import { usePointCursor } from 'store/pointCursor';
10import { useWallet } from 'store/wallet';
12import View from 'components/View';
13import Greeting from 'components/Greeting';
14import Passport from 'components/Passport';
15import Blinky, { matchBlinky } from 'components/Blinky';
16import BarGraph from 'components/BarGraph';
17import Chip from 'components/Chip';
18import InviteSigilList from 'components/InviteSigilList';
19import { ForwardButton } from 'components/Buttons';
21import * as need from 'lib/need';
22import useInvites from 'lib/useInvites';
23import { useSyncExtras } from 'lib/useSyncPoints';
24import useCurrentPermissions from 'lib/useCurrentPermissions';
25import { useLocalRouter } from 'lib/LocalRouter';
27import Inviter from 'views/Invite/Inviter';
28import { usePointCache } from 'store/pointCache';
29import Card from 'components/L2/Card';
30import { Icon, Row } from '@tlon/indigo-react';
31import L2PointHeader from 'components/L2/Headers/L2PointHeader';
32import useRoller from 'lib/useRoller';
33import { useRollerStore } from 'store/roller';
34import LayerIndicator from 'components/L2/LayerIndicator';
35import { convertToInt } from 'lib/convertToInt';
51 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
52 const _pendingInvites = pendingPoints.getOrElse([]).length;
56 <Grid.Item cols={[1, 11]}>
62 className={cn('t-right underline pointer-hover', {
63 gray4: sentInvites.getOrElse(0) === 0,
72 {acceptedInvites.getOrElse(0)} / {_totalInvites}
74 {_pendingInvites > 0 && (
75 <Flex.Item as={Chip} className="bg-yellow1 yellow4">
76 {_pendingInvites} pending
87 available={availableInvites}
89 accepted={acceptedInvites}
94 pendingPoints={pendingPoints}
95 acceptedPoints={acceptedPoints}
101 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
102 <div className="p4 pv8 t-center gray4">
103 Start your invite group by adding members
108 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
114 onClick={() => setShowInviteForm(true)}>
118 {showInviteForm && <Inviter />}
119 <Grid.Item full className="mb2" />
124export default function Point() {
125 const { pop, push, names } = useLocalRouter();
126 const { wallet, authToken } = useWallet();
127 const { pointCursor } = usePointCursor();
128 const point = need.point(pointCursor);
130 const { getResidents } = usePointCache();
131 const { api, getInvites } = useRoller();
139 } = useRollerStore();
142 const loadL2Info = async () => {
143 console.log('POINT', point);
144 const getTransactions = async () => {
145 const pointInfo = await api.getPoint(Number(point));
146 setCurrentPoint(pointInfo);
147 console.log('POINT', pointInfo);
149 if (pointInfo.dominion !== 'l1') {
158 }, [api, point, authToken]); // eslint-disable-line
160 const { residentCount, requestCount } = getResidents(point);
168 } = useCurrentPermissions();
171 const l1Invites = useInvites(point);
180 const showInvites = !(
181 acceptedInvites.getOrElse(0) === 0 && sentInvites.getOrElse(0) === 0
184 const hasInvites = showInvites || availableInvites.getOrElse(0) !== 0;
186 const loadedInvites = Just.hasInstance(availableInvites);
188 // availableInvites.getOrElse(0) === 0
190 const goSenate = useCallback(() => push(names.SENATE), [push, names]);
192 const goCohort = useCallback(() => push(names.INVITE_COHORT), [push, names]);
194 const goUrbitOS = useCallback(() => push(names.URBIT_OS), [push, names]);
196 const goUrbitID = useCallback(() => push(names.URBIT_ID), [push, names]);
198 const goResidents = useCallback(() => push(names.RESIDENTS), [push, names]);
200 const goPartiesSetPoolSize = useCallback(
201 () => push(names.PARTY_SET_POOL_SIZE),
205 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
210 const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
212 const [showInviteForm, setShowInviteForm] = useState(false);
214 const inviteButton = (() => {
215 if (azimuth.getPointSize(point) === azimuth.PointSize.Star) {
221 disabled={!isActiveOwner}
222 onClick={goPartiesSetPoolSize}>
233 const senateButton = (() => {
234 if (azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy) {
251 // sync the current cursor
252 useSyncExtras([point]);
254 const address = need.addressFromWallet(wallet);
256 const _requestCount = requestCount.getOrElse(0);
257 const numPending = pendingTransactions.length;
258 const numInvites = currentL2 ? invites.length : sentInvites.length;
266 <L2PointHeader hideTimer={!!numPending} numInvites={numInvites} />
268 <Greeting point={point} />
270 <div className="transaction">
271 <Row className="title-row">
272 <div className="title">
273 {numPending} Planet{numPending > 1 ? 's' : ''} Spawned
275 <div className="rollup-timer">{nextRoll}</div>
277 <Row className="info-row">
278 <LayerIndicator layer={2} size="sm" />
279 <div className="date"></div>
285 address={Just(address)}
286 animationMode={'slide'}
290 <Grid.Item full as={Flex} justify="between">
293 subtitle="Manage peers that you service"
294 onClick={goResidents}
298 {isPlanet && hasInvites && (
300 showInviteForm={showInviteForm}
301 setShowInviteForm={setShowInviteForm}
302 acceptedInvites={acceptedInvites}
303 acceptedPoints={acceptedPoints}
304 availableInvites={availableInvites}
306 pendingPoints={pendingPoints}
307 sentInvites={sentInvites}
308 showInvites={showInvites}
311 {!loadedInvites && isPlanet && (
312 <Grid.Item className="mv2" full>
313 Invite Group <Blinky />
316 {/* {inviteButton} */}
317 <Grid.Item full as={Flex} justify="between">
320 subtitle="Identity and security settings"
321 icon={<Icon icon="User" />}
323 disabled={!canManage}
326 <Grid.Item full as={Flex} justify="between">
329 subtitle="Urbit OS Settings"
330 icon={<Icon icon="Server" />}
332 disabled={!canManage}
338 disabled={!canBitcoin}
340 detail="Bitcoin management"
350 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