Invite: allow dismissal of join request

Fixes urbit/landscape#782
This commit is contained in:
Liam Fitzgerald 2021-05-10 14:50:56 +10:00
parent edf6456d6c
commit bb03b6f278
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB

View File

@ -206,8 +206,9 @@ function InviteActions(props: {
app?: string; app?: string;
uid?: string; uid?: string;
}) { }) {
const { resource, api, app, uid } = props; const { status, resource, api, app, uid } = props;
const inviteAccept = useInviteAccept(resource, api, app, uid); const inviteAccept = useInviteAccept(resource, api, app, uid);
const set = useGroupState(s => s.set);
const inviteDecline = useCallback(async () => { const inviteDecline = useCallback(async () => {
if (!(app && uid)) { if (!(app && uid)) {
@ -216,15 +217,18 @@ function InviteActions(props: {
await api.invite.decline(app, uid); await api.invite.decline(app, uid);
}, [app, uid]); }, [app, uid]);
const hideJoin = useCallback(async () => { const hideJoin = useCallback(async (e) => {
await api.groups.hide(resource); if(status?.progress === 'done') {
}, [api, resource]); set(s => {
delete s.pendingJoin[resource]
const { status } = props; });
if (status) { e.stopPropagation();
if(status.progress === 'done') { return;
return null;
} }
await api.groups.hide(resource);
}, [api, resource, status]);
if (status) {
return ( return (
<Row gapX="2" alignItems="center" height={4}> <Row gapX="2" alignItems="center" height={4}>
<StatelessAsyncButton <StatelessAsyncButton
@ -232,7 +236,7 @@ function InviteActions(props: {
backgroundColor="white" backgroundColor="white"
onClick={hideJoin} onClick={hideJoin}
> >
Cancel {status?.progress === 'done' ? 'Dismiss' : 'Cancel'}
</StatelessAsyncButton> </StatelessAsyncButton>
</Row> </Row>
); );