See challenges you've accepted too

This commit is contained in:
Ian Philips 2022-08-04 15:58:48 -06:00
parent 798253f887
commit c93f9c5483
2 changed files with 7 additions and 3 deletions

View File

@ -134,11 +134,11 @@ export function listenForUserChallenges(
return listenForValues<Challenge>(listUserChallenges(fromId), setLinks)
}
export const useUserChallenges = (fromId: string) => {
export const useUserChallenges = (fromId?: string) => {
const [links, setLinks] = useState<Challenge[]>([])
useEffect(() => {
return listenForUserChallenges(fromId, setLinks)
if (fromId) return listenForUserChallenges(fromId, setLinks)
}, [fromId])
return links

View File

@ -36,8 +36,12 @@ const amountClass = columnClass + ' max-w-[75px] font-bold'
export default function ChallengesListPage() {
const user = useUser()
const userChallenges = useUserChallenges(user?.id ?? '')
const challenges = useAcceptedChallenges()
const userChallenges = useUserChallenges(user?.id)
.concat(
user ? challenges.filter((c) => c.acceptances[0].userId === user.id) : []
)
.sort((a, b) => b.createdTime - a.createdTime)
const userTab = user
? [