From 5034a43c3ccb2f4b38043524af728bd885947bf6 Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Fri, 1 Jul 2022 08:29:12 -0600 Subject: [PATCH] Filter for ian's deleted users --- functions/src/on-update-user.ts | 20 ++++++++++++-------- web/hooks/use-group.ts | 4 +++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/functions/src/on-update-user.ts b/functions/src/on-update-user.ts index 2e5e2145..b6ba6e0b 100644 --- a/functions/src/on-update-user.ts +++ b/functions/src/on-update-user.ts @@ -55,14 +55,18 @@ async function handleUserUpdatedReferral(user: User, eventId: string) { .where('category', '==', 'REFERRAL') .get() ).docs.map((txn) => txn.ref) - const referralTxns = await transaction.getAll(...txns).catch((err) => { - console.error('error getting txns:', err) - throw err - }) - // If the referring user already has a referral txn due to referring this user, halt - if (referralTxns.map((txn) => txn.data()?.description).includes(user.id)) { - console.log('found referral txn with the same details, aborting') - return + if (txns.length > 0) { + const referralTxns = await transaction.getAll(...txns).catch((err) => { + console.error('error getting txns:', err) + throw err + }) + // If the referring user already has a referral txn due to referring this user, halt + if ( + referralTxns.map((txn) => txn.data()?.description).includes(user.id) + ) { + console.log('found referral txn with the same details, aborting') + return + } } console.log('creating referral txns') const fromId = HOUSE_LIQUIDITY_PROVIDER_ID diff --git a/web/hooks/use-group.ts b/web/hooks/use-group.ts index 41f84707..39f6f3f8 100644 --- a/web/hooks/use-group.ts +++ b/web/hooks/use-group.ts @@ -74,7 +74,9 @@ export function useMembers(group: Group) { } export async function listMembers(group: Group) { - return await Promise.all(group.memberIds.map(getUser)) + return (await Promise.all(group.memberIds.map(getUser))).filter( + (user) => user + ) } export const useGroupsWithContract = (contractId: string | undefined) => {