1import React, { useCallback, useState, useEffect } from 'react';
2import cn from 'classnames';
3import { Just } from 'folktale/maybe';
4import { Grid, Flex, Button } from 'indigo-react';
5import { azimuth } from 'azimuth-js';
7import { usePointCursor } from 'store/pointCursor';
8import { useWallet } from 'store/wallet';
10import View from 'components/View';
11import Greeting from 'components/Greeting';
12import Passport from 'components/Passport';
13import Blinky, { matchBlinky } from 'components/Blinky';
14import BarGraph from 'components/BarGraph';
15import Chip from 'components/Chip';
16import InviteSigilList from 'components/InviteSigilList';
17import { ForwardButton, HostingButton } from 'components/Buttons';
18import CopyButton from 'components/CopyButton';
19import DownloadSigilButton from 'components/DownloadSigilButton';
21import * as need from 'lib/need';
22import useInvites from 'lib/useInvites';
23import { useSyncOwnedPoints } from 'lib/useSyncPoints';
24import useCurrentPermissions from 'lib/useCurrentPermissions';
25import { useLocalRouter } from 'lib/LocalRouter';
27import Inviter from 'views/Invite/Inviter';
28import { usePointCache } from 'store/pointCache';
30export default function Point() {
31 const { pop, push, names } = useLocalRouter();
32 const { pointCursor } = usePointCursor();
34 const { wallet } = useWallet();
35 const point = need.point(pointCursor);
37 const { getResidents } = usePointCache();
39 const { residentCount, requestCount } = getResidents(point);
47 } = useCurrentPermissions();
49 // fetch the invites for the current cursor
50 const invites = useInvites(point);
59 const showInvites = !(
60 acceptedInvites.getOrElse(0) === 0 && sentInvites.getOrElse(0) === 0
63 const hasInvites = showInvites || availableInvites.getOrElse(0) !== 0;
66 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
67 const _pendingInvites = pendingPoints.getOrElse([]).length;
69 const loadedInvites = Just.hasInstance(availableInvites);
71 // availableInvites.getOrElse(0) === 0
73 const goSenate = useCallback(() => push(names.SENATE), [push, names]);
75 const goSigil = useCallback(() => push(names.SIGIL_GENERATOR), [push, names]);
77 const goCohort = useCallback(() => push(names.INVITE_COHORT), [push, names]);
79 const goUrbitOS = useCallback(() => push(names.URBIT_OS), [push, names]);
81 const goUrbitID = useCallback(() => push(names.URBIT_ID), [push, names]);
83 const goResidents = useCallback(() => push(names.RESIDENTS), [push, names]);
85 const goPartiesSetPoolSize = useCallback(
86 () => push(names.PARTY_SET_POOL_SIZE),
90 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
95 const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
97 const [showInviteForm, setShowInviteForm] = useState(false);
99 const goBoot = useCallback(() => push(names.BOOT), [push, names]);
100 const goHosting = useCallback(() => push(names.HOSTING), [push, names]);
102 const inviteButton = (() => {
103 if (azimuth.getPointSize(point) === azimuth.PointSize.Star) {
109 disabled={!isActiveOwner}
110 onClick={goPartiesSetPoolSize}>
121 const senateButton = (() => {
122 if (azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy) {
139 // sync the current cursor
140 useSyncOwnedPoints([point]);
142 const address = need.addressFromWallet(wallet);
144 const InviteForm = useCallback(() => {
147 <Grid.Item cols={[1, 11]}>
153 className={cn('t-right underline pointer-hover', {
154 gray4: sentInvites.getOrElse(0) === 0,
161 <Flex align="center">
163 {acceptedInvites.getOrElse(0)} / {_totalInvites}
165 {_pendingInvites > 0 && (
166 <Flex.Item as={Chip} className="bg-yellow1 yellow4">
167 {_pendingInvites} pending
178 available={availableInvites}
180 accepted={acceptedInvites}
185 pendingPoints={pendingPoints}
186 acceptedPoints={acceptedPoints}
192 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
193 <div className="p4 pv8 t-center gray4">
194 Start your invite group by adding members
199 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
205 onClick={() => setShowInviteForm(true)}>
209 {showInviteForm && <Inviter />}
210 <Grid.Item full className="mb2" />
215 const _requestCount = requestCount.getOrElse(0);
218 <View pop={pop} inset>
219 <Greeting point={point} />
222 address={Just(address)}
223 animationMode={'slide'}
231 onClick={goResidents}
235 <span className="gray3">{matchBlinky(residentCount)}</span>
237 {_requestCount !== 0 && (
238 <Flex.Item className="f7 bg-gray2 h3 pv1 ph2 br-full r-full text-center">
239 {_requestCount} PENDING
244 {isPlanet && hasInvites && <InviteForm />}
245 {!loadedInvites && isPlanet && (
246 <Grid.Item className="mv2" full>
247 Invite Group <Blinky />
251 <Grid className="pt2">
257 disabled={!canManage}
260 detail="Identity and security settings">
267 disabled={!canManage}
269 detail="Urbit OS Settings"
280 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