diff --git a/pkg/interface/src/views/apps/notifications/inbox.tsx b/pkg/interface/src/views/apps/notifications/inbox.tsx index 1fb35dc290..be890e5056 100644 --- a/pkg/interface/src/views/apps/notifications/inbox.tsx +++ b/pkg/interface/src/views/apps/notifications/inbox.tsx @@ -10,6 +10,7 @@ import GlobalApi from "~/logic/api/global"; import { Notification } from "./notification"; import { Associations } from "~/types"; import { cite } from '~/logic/lib/util'; +import { InviteItem } from '~/views/components/Invite'; type DatedTimebox = [BigInteger, Timebox]; @@ -77,52 +78,28 @@ export default function Inbox(props: { } }, [api]); - const incomingGroups = Object.values(invites?.['contacts'] || {}); - - const getKeyByValue = (object, value) => { - return Object.keys(object).find(key => object[key] === value); - }; - - const acceptInvite = (invite) => { - const resource = { - ship: `~${invite.resource.ship}`, - name: invite.resource.name - }; - return api.contacts.join(resource).then(() => { - api.invite.accept('contacts', getKeyByValue(invites['contacts'], invite)); + const inviteItems = (invites, api) => { + const returned = []; + Object.keys(invites).map((appKey) => { + const app = invites[appKey]; + Object.keys(app).map((uid) => { + const invite = app[uid]; + const inviteItem = + api.invite.accept(appKey, uid)} + onDecline={() => api.invite.decline(appKey, uid)} + />; + returned.push(inviteItem); + }); }); + return returned; }; return ( - {incomingGroups.map((invite) => ( - - {cite(invite.resource.ship)} invited you to {invite.resource.name} - - acceptInvite(invite)} - color='blue' - mr='2' - cursor='pointer'> - Accept - - - api.invite.decline( - 'contacts', - getKeyByValue(invites['contacts'], invite) - ) - } - cursor='pointer'> - Reject - - - - ))} + {inviteItems(invites, api)} {newNotifications && ( { +export class InviteItem extends Component<{invite: Invite, onAccept: Function, onDecline: Function}, {}> { render() { const { props } = this; return ( - You have been invited to: - - {`~${props.invite.resource.ship}/${props.invite.resource.name}`} - + {cite(props.invite.resource.ship)} invited you to {props.invite.resource.name}