From 5ebd4498a0780f17a9d6f39ed174abf85c7e72c7 Mon Sep 17 00:00:00 2001 From: Sinclair Chen Date: Wed, 13 Jul 2022 17:43:20 -0700 Subject: [PATCH] Remove deprecated useUserById implementation (#571) * Remove duplicate useUserById implementation * fix bug: firebase doesn't accept empty paths --- web/components/charity/feed-items.tsx | 2 +- web/hooks/use-users.ts | 13 ------------- web/pages/[username]/[contractSlug].tsx | 2 +- web/pages/link/[slug].tsx | 4 ++-- web/pages/links.tsx | 2 +- 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/web/components/charity/feed-items.tsx b/web/components/charity/feed-items.tsx index 6e6def00..365aa606 100644 --- a/web/components/charity/feed-items.tsx +++ b/web/components/charity/feed-items.tsx @@ -1,6 +1,6 @@ import { DonationTxn } from 'common/txn' import { Avatar } from '../avatar' -import { useUserById } from 'web/hooks/use-users' +import { useUserById } from 'web/hooks/use-user' import { UserLink } from '../user-page' import { manaToUSD } from '../../../common/util/format' import { RelativeTimestamp } from '../relative-timestamp' diff --git a/web/hooks/use-users.ts b/web/hooks/use-users.ts index 1a527659..1312444e 100644 --- a/web/hooks/use-users.ts +++ b/web/hooks/use-users.ts @@ -1,7 +1,6 @@ import { useState, useEffect } from 'react' import { PrivateUser, User } from 'common/user' import { - getUser, listenForAllUsers, listenForPrivateUsers, } from 'web/lib/firebase/users' @@ -20,18 +19,6 @@ export const useUsers = () => { return users } -export const useUserById = (userId?: string) => { - const [user, setUser] = useState(undefined) - - useEffect(() => { - if (userId) { - getUser(userId).then(setUser) - } - }, [userId]) - - return user -} - export const usePrivateUsers = () => { const [users, setUsers] = useState([]) diff --git a/web/pages/[username]/[contractSlug].tsx b/web/pages/[username]/[contractSlug].tsx index bfe13837..0cfbc99f 100644 --- a/web/pages/[username]/[contractSlug].tsx +++ b/web/pages/[username]/[contractSlug].tsx @@ -27,7 +27,7 @@ import { fromPropz, usePropz } from 'web/hooks/use-propz' import { Leaderboard } from 'web/components/leaderboard' import { resolvedPayout } from 'common/calculate' import { formatMoney } from 'common/util/format' -import { useUserById } from 'web/hooks/use-users' +import { useUserById } from 'web/hooks/use-user' import { ContractTabs } from 'web/components/contract/contract-tabs' import { contractTextDetails } from 'web/components/contract/contract-details' import { useWindowSize } from 'web/hooks/use-window-size' diff --git a/web/pages/link/[slug].tsx b/web/pages/link/[slug].tsx index 01597a15..8093969b 100644 --- a/web/pages/link/[slug].tsx +++ b/web/pages/link/[slug].tsx @@ -6,7 +6,7 @@ import { claimManalink } from 'web/lib/firebase/api' import { useManalink } from 'web/lib/firebase/manalinks' import { ManalinkCard } from 'web/components/manalink-card' import { useUser } from 'web/hooks/use-user' -import { useUserById } from 'web/hooks/use-users' +import { useUserById } from 'web/hooks/use-user' import { firebaseLogin } from 'web/lib/firebase/users' export default function ClaimPage() { @@ -17,7 +17,7 @@ export default function ClaimPage() { const [claiming, setClaiming] = useState(false) const [error, setError] = useState(undefined) - const fromUser = useUserById(manalink?.fromId) + const fromUser = useUserById(manalink?.fromId ?? '_loading') if (!manalink) { return <> } diff --git a/web/pages/links.tsx b/web/pages/links.tsx index ede997df..76c62978 100644 --- a/web/pages/links.tsx +++ b/web/pages/links.tsx @@ -12,7 +12,7 @@ import { Subtitle } from 'web/components/subtitle' import { useUser } from 'web/hooks/use-user' import { useUserManalinks } from 'web/lib/firebase/manalinks' import { fromNow } from 'web/lib/util/time' -import { useUserById } from 'web/hooks/use-users' +import { useUserById } from 'web/hooks/use-user' import { ManalinkTxn } from 'common/txn' import { Avatar } from 'web/components/avatar' import { RelativeTimestamp } from 'web/components/relative-timestamp'