From 1e180f420af98e40352d1ca464018bc541fd8bfc Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Wed, 24 Nov 2021 13:18:40 -0500 Subject: [PATCH] interface: address hunter review --- pkg/interface/src/logic/state/group.ts | 3 +-- pkg/interface/src/logic/state/invite.ts | 14 ++++++++------ pkg/interface/src/views/apps/launch/App.tsx | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/interface/src/logic/state/group.ts b/pkg/interface/src/logic/state/group.ts index dce2bbb9e..64e002714 100644 --- a/pkg/interface/src/logic/state/group.ts +++ b/pkg/interface/src/logic/state/group.ts @@ -1,4 +1,4 @@ -import { Association, Group, JoinRequests } from '@urbit/api'; +import { Association, Group, JoinRequests, abortJoin } from '@urbit/api'; import { useCallback } from 'react'; import { reduce } from '../reducers/group-update'; import _ from 'lodash'; @@ -9,7 +9,6 @@ import { reduceStateN } from './base'; import api from '~/logic/api'; -import { abortJoin } from '@urbit/api'; export interface GroupState { groups: { diff --git a/pkg/interface/src/logic/state/invite.ts b/pkg/interface/src/logic/state/invite.ts index 58a8b8fb3..d9a3d186f 100644 --- a/pkg/interface/src/logic/state/invite.ts +++ b/pkg/interface/src/logic/state/invite.ts @@ -1,4 +1,4 @@ -import { deSig, Invites } from '@urbit/api'; +import { deSig, Invite, Invites } from '@urbit/api'; import { reduce } from '../reducers/invite-update'; import _ from 'lodash'; import { @@ -32,9 +32,11 @@ export default useInviteState; export function useInviteForResource(app: string, ship: string, name: string) { const { invites } = useInviteState(); - return _.compact(Object.entries(invites?.[app] || {}).map(([uid, invite]) => { - if (invite.resource.ship === deSig(ship) && invite.resource.name === name) { - return invite; - } - }))?.[0]; + const matches = Object.entries(invites?.[app] || {}) + .reduce((acc, [uid, invite]) => { + const isMatch = (invite.resource.ship === deSig(ship) + && invite.resource.name === name) + return isMatch ? [invite, ...acc] : acc; + }, [] as Invite[]) + return matches?.[0]; } diff --git a/pkg/interface/src/views/apps/launch/App.tsx b/pkg/interface/src/views/apps/launch/App.tsx index d2bdf8756..9df5c30df 100644 --- a/pkg/interface/src/views/apps/launch/App.tsx +++ b/pkg/interface/src/views/apps/launch/App.tsx @@ -91,7 +91,7 @@ export const LaunchApp = (props: LaunchAppProps): ReactElement | null => {