1import { useCallback, useEffect, useState } from 'react';
2import { Box, Row } from '@tlon/indigo-react';
3import { Ship } from '@urbit/roller-api';
5import { useRollerStore } from 'store/rollerStore';
6import useRoller from 'lib/useRoller';
7import { useLocalRouter } from 'lib/LocalRouter';
9import Window from 'components/L2/Window/Window';
10import HeaderPane from 'components/L2/Window/HeaderPane';
11import BodyPane from 'components/L2/Window/BodyPane';
12import View from 'components/View';
13import L2BackHeader from 'components/L2/Headers/L2BackHeader';
15import { ResidentRow } from './ResidentRow';
16import './Residents.scss';
18export const Residents = () => {
19 const { pop }: any = useLocalRouter();
20 const { point, setLoading } = useRollerStore();
21 const { api, changeSponsorship } = useRoller();
22 const [sponsoredPoints, setSponsoredPoints] = useState<Ship[]>([]);
24 const fetchResidents = useCallback(async () => {
30 // TODO: remove this hack once the API is updated
31 const { residentes, residents } = await api.getSponsoredPoints(point.value);
32 setSponsoredPoints((residents || residentes || []).sort());
34 }, [api, point, setLoading]);
36 const handleKick = useCallback(
37 async (ship: Ship) => {
39 await changeSponsorship(ship, 'detach', point.isL1);
40 await fetchResidents();
43 [setLoading, changeSponsorship, point.isL1, fetchResidents]
52 className="ops-residents"
56 header={<L2BackHeader hideBalance back={pop} />}>
59 <Row className="header-row">
62 <span className="header-count">{sponsoredPoints.length}</span>
67 <Box className="content-container">
68 {sponsoredPoints.length > 0 ? (
69 <ul className="residents-list">
70 {sponsoredPoints.map(sp => (
71 <ResidentRow key={sp} point={sp} onKick={handleKick} />
75 <Box className="no-results">No residents</Box>
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