1import React, { useCallback, useMemo } from 'react';
2import { Just } from 'folktale/maybe';
3import * as need from 'lib/need';
4import { Grid } from 'indigo-react';
5import { azimuth } from 'azimuth-js';
7import { usePointCursor } from 'store/pointCursor';
8import { useHistory } from 'store/history';
10import View from 'components/View';
11import Passport from 'components/Passport';
12import { ForwardButton } from 'components/Buttons';
13import FooterButton from 'components/FooterButton';
14import { matchBlinky } from 'components/Blinky';
16import useInvites from 'lib/useInvites';
17import { useSyncOwnedPoints } from 'lib/useSyncPoints';
18import { ROUTE_NAMES } from 'lib/routeNames';
20import Actions from './Point/Actions';
21import { useWallet } from 'store/wallet';
22import usePermissionsForPoint from 'lib/usePermissionsForPoint';
24const isPlanet = point =>
25 azimuth.getPointSize(point) === azimuth.PointSize.Planet;
27export default function Point() {
28 const history = useHistory();
29 const { pointCursor } = usePointCursor();
30 const { wallet } = useWallet();
32 const point = need.point(pointCursor);
34 const { isOwner, canManage } = usePermissionsForPoint(
35 // using empty string should be ok here
38 Just: p => p.value.address,
43 // fetch the invites for the current cursor
44 const { availableInvites } = useInvites(point);
46 const showActions = Just.hasInstance(wallet);
48 const goAdmin = useCallback(() => history.push(ROUTE_NAMES.ADMIN), [history]);
50 const goInvite = useCallback(() => history.push(ROUTE_NAMES.INVITE), [
54 const inviteButton = useMemo(() => {
55 switch (azimuth.getPointSize(point)) {
56 case azimuth.PointSize.Planet:
57 const availableInvitesText = matchBlinky(availableInvites);
58 const goInvite = () => history.push(ROUTE_NAMES.INVITE);
60 <FooterButton disabled={!isOwner} onClick={goInvite}>
61 Invite <sup>{availableInvitesText} available</sup>
65 case azimuth.PointSize.Star:
66 const goParties = () => history.push(ROUTE_NAMES.INVITES_MANAGE);
68 <FooterButton disabled={!isOwner} onClick={goParties}>
76 }, [point, history, isOwner, availableInvites]);
78 // sync the current cursor
79 useSyncOwnedPoints([point]);
83 <Passport point={Just(point)} />
84 <Grid className="pt2">
93 <Grid.Item full as={ForwardButton} detail="Boot your computer" disabled>
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