mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-12 15:01:38 +03:00
inbox: redirect invites correctly
This commit is contained in:
parent
d85af3c7e0
commit
7aecffb90f
@ -87,15 +87,24 @@ export default function Inbox(props: {
|
||||
}
|
||||
}, [props.showArchive]);
|
||||
|
||||
const acceptInvite = async (invite) => {
|
||||
const acceptInvite = (app: string, uid: string) => async (invite) => {
|
||||
const resource = {
|
||||
ship: `~${invite.resource.ship}`,
|
||||
name: invite.resource.name
|
||||
};
|
||||
await api.contacts.join(resource);
|
||||
await api.invite.accept('contacts', getKeyByValue(invites['contacts'], invite));
|
||||
const path = resourceAsPath(invite.resource)
|
||||
await waiter(p => path in p.associations?.contacts);
|
||||
|
||||
let resourcePath = resourceAsPath(invite.resource);
|
||||
if(app === 'chat') {
|
||||
resourcePath = resourcePath.slice(5);
|
||||
}
|
||||
|
||||
let path = `/home/resource/${app}${resourcePath}`;
|
||||
if(app === 'contacts') {
|
||||
await api.contacts.join(resource);
|
||||
path = resourceAsPath(invite.resource);
|
||||
await waiter(p => path in p.associations?.contacts);
|
||||
}
|
||||
await api.invite.accept(app, uid);
|
||||
|
||||
history.push(`/~landscape${path}`);
|
||||
};
|
||||
@ -110,7 +119,7 @@ export default function Inbox(props: {
|
||||
<InviteItem
|
||||
key={uid}
|
||||
invite={invite}
|
||||
onAccept={acceptInvite}
|
||||
onAccept={acceptInvite(appKey, uid)}
|
||||
onDecline={() => api.invite.decline(appKey, uid)}
|
||||
/>;
|
||||
returned.push(inviteItem);
|
||||
|
Loading…
Reference in New Issue
Block a user