1import React, { useState, useEffect, useCallback, useMemo } from 'react';
2import { Grid, H4, HelpText } from 'indigo-react';
3import { Just, Nothing } from 'folktale/maybe';
4import * as ob from 'urbit-ob';
6import View from 'components/View';
7import Tabs from 'components/Tabs';
8import Crumbs from 'components/Crumbs';
9import Sigil from 'components/Sigil';
10import Blinky from 'components/Blinky';
11import NavHeader from 'components/NavHeader';
13import { useLocalRouter } from 'lib/LocalRouter';
14import useCurrentPointName from 'lib/useCurrentPointName';
15import * as need from 'lib/need';
17import { usePointCursor } from 'store/pointCursor';
18import { usePointCache } from 'store/pointCache';
26 { text: 'Requests', value: NAMES.REQUESTS },
27 { text: 'All', value: NAMES.ALL },
31 [NAMES.REQUESTS]: Tab,
35function Tab({ className, points, onAccept, onDecline }) {
36 if (Nothing.hasInstance(points)) {
37 return <Grid className={className}></Grid>;
40 const _points = points.getOrElse([]);
43 <Grid className={className}>
44 {_points.length === 0 && (
45 <Grid.Item full as={HelpText} className="mt8 t-center">
46 {Just.hasInstance(points) ? (
47 'No points to display'
56 {_points.map(point => (
68function Resident({ point, onAccept, onDecline }) {
69 const patp = ob.patp(point);
72 const isRequest = onAccept && onDecline;
76 <Grid.Item className="flex-row justify-center align-center" cols={[1, 3]}>
79 display: 'inline-block',
80 height: `${sigilSize}px`,
81 width: `${sigilSize}px`,
83 <Sigil patp={patp} size={25} colors={['#FFFFFF', '#000000']} />
86 <Grid.Item className="flex-row align-center" cols={[3, 6]}>
92 className="flex-row-r align-center underline green3 pointer"
94 onClick={() => onAccept(point)}>
98 className="flex-row-r align-center underline red4 pointer"
100 onClick={() => onDecline(point)}>
110export default function Residents() {
111 const { pop, push, names } = useLocalRouter();
112 const name = useCurrentPointName();
114 const { pointCursor } = usePointCursor();
115 const point = need.point(pointCursor);
116 const { getResidents, syncResidents } = usePointCache();
119 syncResidents(point);
120 }, [syncResidents, point]);
122 const { residents, requests } = getResidents(point);
124 const [currentTab, setCurrentTab] = useState(NAMES.ALL);
126 const isRequests = useMemo(() => currentTab === NAMES.REQUESTS, [currentTab]);
128 const _onAccept = useCallback(adoptee =>
134 const onAccept = isRequests && _onAccept;
136 const _onDecline = useCallback(adoptee =>
142 const onDecline = isRequests && _onDecline;
144 const points = isRequests ? requests : residents;
147 <View pop={pop} inset>
149 <Crumbs routes={[{ text: name, action: pop }, { text: 'Residents' }]} />
152 <Grid.Item full as={H4} className="mt4">
162 currentTab={currentTab}
163 onTabChange={setCurrentTab}
167 onDecline={onDecline}
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