From 78c461b26cb02fb56f57f0af4d7e5fca32c841fe Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Wed, 19 Jan 2022 02:33:46 -0500 Subject: [PATCH] Show creator avatar in feed --- common/contract.ts | 2 +- web/components/contract-feed.tsx | 49 +++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/common/contract.ts b/common/contract.ts index 9b9d428d..5e344f09 100644 --- a/common/contract.ts +++ b/common/contract.ts @@ -5,7 +5,7 @@ export type Contract = { creatorId: string creatorName: string creatorUsername: string - creatorAvatarUrl?: string // Start requiring after Mar 01, 2022 + creatorAvatarUrl?: string // Start requiring after 2022-03-01 question: string description: string // More info about what the contract is about diff --git a/web/components/contract-feed.tsx b/web/components/contract-feed.tsx index f79784df..69316937 100644 --- a/web/components/contract-feed.tsx +++ b/web/components/contract-feed.tsx @@ -1,5 +1,5 @@ // From https://tailwindui.com/components/application-ui/lists/feeds -import { useState } from 'react' +import { ReactChild, useState } from 'react' import _ from 'lodash' import { BanIcon, @@ -40,6 +40,27 @@ import { Comment, mapCommentsByBetId } from '../lib/firebase/comments' import { JoinSpans } from './join-spans' import Textarea from 'react-expanding-textarea' +function AvatarWithIcon(props: { + username: string + avatarUrl: string + children: ReactChild +}) { + const { username, avatarUrl, children } = props + return ( + + + + + {children} + + + ) +} + function FeedComment(props: { activityItem: any }) { const { activityItem } = props const { person, text, amount, outcome, createdTime } = activityItem @@ -49,17 +70,9 @@ function FeedComment(props: { activityItem: any }) { return ( <> - - - - - - + +

@@ -246,13 +259,21 @@ function FeedQuestion(props: { contract: Contract }) { return ( <> -

+ {contract.creatorAvatarUrl ? ( + + + ) : ( + // TODO: After 2022-03-01, can just assume that all contracts have an avatarUrl
-
+ )}