1import React, { useCallback, useState } 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 } from 'components/Buttons';
19import * as need from 'lib/need';
20import useInvites from 'lib/useInvites';
21import { useSyncOwnedPoints } from 'lib/useSyncPoints';
22import useCurrentPermissions from 'lib/useCurrentPermissions';
23import { useLocalRouter } from 'lib/LocalRouter';
25import Inviter from 'views/Invite/Inviter';
26import { usePointCache } from 'store/pointCache';
28export default function Point() {
29 const { pop, push, names } = useLocalRouter();
30 const { pointCursor } = usePointCursor();
32 const { wallet } = useWallet();
33 const point = need.point(pointCursor);
35 const { getResidents } = usePointCache();
37 const { residentCount, requestCount } = getResidents(point);
45 } = useCurrentPermissions();
47 // fetch the invites for the current cursor
48 const invites = useInvites(point);
57 const showInvites = !(
58 acceptedInvites.getOrElse(0) === 0 && sentInvites.getOrElse(0) === 0
61 const hasInvites = showInvites || availableInvites.getOrElse(0) !== 0;
64 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
65 const _pendingInvites = pendingPoints.getOrElse([]).length;
67 const loadedInvites = Just.hasInstance(availableInvites);
69 // availableInvites.getOrElse(0) === 0
71 const goSenate = useCallback(() => push(names.SENATE), [push, names]);
73 const goCohort = useCallback(() => push(names.INVITE_COHORT), [push, names]);
75 const goUrbitOS = useCallback(() => push(names.URBIT_OS), [push, names]);
77 const goUrbitID = useCallback(() => push(names.URBIT_ID), [push, names]);
79 const goResidents = useCallback(() => push(names.RESIDENTS), [push, names]);
81 const goPartiesSetPoolSize = useCallback(
82 () => push(names.PARTY_SET_POOL_SIZE),
86 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
91 const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
93 const [showInviteForm, setShowInviteForm] = useState(false);
95 const inviteButton = (() => {
96 if (azimuth.getPointSize(point) === azimuth.PointSize.Star) {
102 disabled={!isActiveOwner}
103 onClick={goPartiesSetPoolSize}>
114 const senateButton = (() => {
115 if (azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy) {
132 // sync the current cursor
133 useSyncOwnedPoints([point]);
135 const address = need.addressFromWallet(wallet);
137 const InviteForm = useCallback(() => {
140 <Grid.Item cols={[1, 11]}>
146 className={cn('t-right underline pointer-hover', {
147 gray4: sentInvites.getOrElse(0) === 0,
154 <Flex align="center">
156 {acceptedInvites.getOrElse(0)} / {_totalInvites}
158 {_pendingInvites > 0 && (
159 <Flex.Item as={Chip} className="bg-yellow1 yellow4">
160 {_pendingInvites} pending
171 available={availableInvites}
173 accepted={acceptedInvites}
178 pendingPoints={pendingPoints}
179 acceptedPoints={acceptedPoints}
185 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
186 <div className="p4 pv8 t-center gray4">
187 Start your invite group by adding members
192 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
198 onClick={() => setShowInviteForm(true)}>
202 {showInviteForm && <Inviter />}
203 <Grid.Item full className="mb2" />
220 const _requestCount = requestCount.getOrElse(0);
223 <View pop={pop} inset>
224 <Greeting point={point} />
227 address={Just(address)}
228 animationMode={'slide'}
236 onClick={goResidents}
240 <span className="gray3">{matchBlinky(residentCount)}</span>
242 {_requestCount !== 0 && (
243 <Flex.Item className="f7 bg-gray2 h3 pv1 ph2 br-full r-full text-center">
244 {_requestCount} PENDING
249 {isPlanet && hasInvites && <InviteForm />}
250 {!loadedInvites && isPlanet && (
251 <Grid.Item className="mv2" full>
252 Invite Group <Blinky />
256 <Grid className="pt2">
262 disabled={!canManage}
265 detail="Identity and security settings">
272 disabled={!canManage}
274 detail="Urbit OS Settings"
285 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