1import React, { useCallback, useEffect, useState } from 'react';
2import cn from 'classnames';
3import { Just } from 'folktale/maybe';
4import { Grid, Flex, Button } from 'indigo-react';
5import { Icon, Row } from '@tlon/indigo-react';
6import { azimuth } from 'azimuth-js';
8import { usePointCursor } from 'store/pointCursor';
9import { useWallet } from 'store/wallet';
10import { usePointCache } from 'store/pointCache';
11import { useRollerStore } from 'store/roller';
13import View from 'components/View';
14import Greeting from 'components/Greeting';
15import Passport from 'components/Passport';
16import Blinky from 'components/Blinky';
17import BarGraph from 'components/BarGraph';
18import Chip from 'components/Chip';
19import InviteSigilList from 'components/InviteSigilList';
20import { ForwardButton } from 'components/Buttons';
21import L2PointHeader from 'components/L2/Headers/L2PointHeader';
22import LayerIndicator from 'components/L2/LayerIndicator';
23import Card from 'components/L2/Card';
25import * as need from 'lib/need';
26import useInvites from 'lib/useInvites';
27import { useSyncExtras } from 'lib/useSyncPoints';
28import useCurrentPermissions from 'lib/useCurrentPermissions';
29import { useLocalRouter } from 'lib/LocalRouter';
30import Inviter from 'views/Invite/Inviter';
31import useRoller from 'lib/useRoller';
47 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
48 const _pendingInvites = pendingPoints.getOrElse([]).length;
52 <Grid.Item cols={[1, 11]}>
58 className={cn('t-right underline pointer-hover', {
59 gray4: sentInvites.getOrElse(0) === 0,
68 {acceptedInvites.getOrElse(0)} / {_totalInvites}
70 {_pendingInvites > 0 && (
71 <Flex.Item as={Chip} className="bg-yellow1 yellow4">
72 {_pendingInvites} pending
83 available={availableInvites}
85 accepted={acceptedInvites}
90 pendingPoints={pendingPoints}
91 acceptedPoints={acceptedPoints}
97 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
98 <div className="p4 pv8 t-center gray4">
99 Start your invite group by adding members
104 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
110 onClick={() => setShowInviteForm(true)}>
114 {showInviteForm && <Inviter />}
115 <Grid.Item full className="mb2" />
120export default function Point() {
121 const { pop, push, names } = useLocalRouter();
122 const { wallet, authToken } = useWallet();
123 const { pointCursor } = usePointCursor();
124 const point = need.point(pointCursor);
126 const { getResidents } = usePointCache();
127 const { api, getInvites } = useRoller();
134 setPendingTransactions,
135 } = useRollerStore();
137 const [loaded, setLoaded] = useState(false);
140 const loadL2Info = async () => {
141 const getTransactions = async () => {
142 const pointInfo = await api.getPoint(Number(point));
143 setCurrentPoint(pointInfo);
155 }, [api, point, authToken, setPendingTransactions, loaded]); // eslint-disable-line
157 const { residentCount, requestCount } = getResidents(point);
165 } = useCurrentPermissions();
168 const l1Invites = useInvites(point);
177 const showInvites = !(
178 acceptedInvites.getOrElse(0) === 0 && sentInvites.getOrElse(0) === 0
181 const hasInvites = showInvites || availableInvites.getOrElse(0) !== 0;
183 const loadedInvites = Just.hasInstance(availableInvites);
185 // availableInvites.getOrElse(0) === 0
187 const goSenate = useCallback(() => push(names.SENATE), [push, names]);
189 const goCohort = useCallback(() => push(names.INVITE_COHORT), [push, names]);
191 const goUrbitOS = useCallback(() => push(names.URBIT_OS), [push, names]);
193 const goUrbitID = useCallback(() => push(names.URBIT_ID), [push, names]);
195 const goResidents = useCallback(() => push(names.RESIDENTS), [push, names]);
197 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
202 const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
204 const [showInviteForm, setShowInviteForm] = useState(false);
206 const senateButton = (() => {
207 if (azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy) {
224 // sync the current cursor
225 useSyncExtras([point]);
227 const address = need.addressFromWallet(wallet);
229 const _requestCount = requestCount.getOrElse(0);
230 const numPending = pendingTransactions.length;
238 <L2PointHeader hideTimer={!!numPending} numInvites={invites.length} />
240 <Greeting point={point} />
242 <div className="transaction">
243 <Row className="title-row">
244 <div className="title">
245 {numPending} Planet{numPending > 1 ? 's' : ''} Spawned
247 <div className="rollup-timer">{nextRoll}</div>
249 <Row className="info-row">
250 <LayerIndicator layer={2} size="sm" />
251 <div className="date"></div>
257 address={Just(address)}
258 animationMode={'slide'}
262 <Grid.Item full as={Flex} justify="between">
265 subtitle="Manage peers that you service"
266 onClick={goResidents}
270 {isPlanet && hasInvites && (
272 showInviteForm={showInviteForm}
273 setShowInviteForm={setShowInviteForm}
274 acceptedInvites={acceptedInvites}
275 acceptedPoints={acceptedPoints}
276 availableInvites={availableInvites}
278 pendingPoints={pendingPoints}
279 sentInvites={sentInvites}
280 showInvites={showInvites}
283 {!loadedInvites && isPlanet && (
284 <Grid.Item className="mv2" full>
285 Invite Group <Blinky />
288 {/* {inviteButton} */}
289 <Grid.Item full as={Flex} justify="between">
292 subtitle="Identity and security settings"
293 icon={<Icon icon="User" />}
295 disabled={!canManage}
298 <Grid.Item full as={Flex} justify="between">
301 subtitle="Urbit OS Settings"
302 icon={<Icon icon="Server" />}
304 disabled={!canManage}
310 disabled={!canBitcoin}
312 detail="Bitcoin management"
322 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