Represent DB avatar URLs as non-null (#128)

This commit is contained in:
Marshall Polaris 2022-05-04 11:07:22 -07:00 committed by GitHub
parent 899c6ab0e0
commit bf8e09b6c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 12 deletions

View File

@ -9,7 +9,7 @@ export type Answer = {
userId: string
username: string
name: string
avatarUrl?: string
avatarUrl: string
text: string
}

View File

@ -13,5 +13,5 @@ export type Comment = {
// Denormalized, for rendering comments
userName: string
userUsername: string
userAvatarUrl?: string
userAvatarUrl: string
}

View File

@ -11,7 +11,7 @@ export type FullContract<
creatorId: string
creatorName: string
creatorUsername: string
creatorAvatarUrl?: string // Start requiring after 2022-03-01
creatorAvatarUrl: string
question: string
description: string // More info about what the contract is about

View File

@ -4,7 +4,7 @@ export type User = {
name: string
username: string
avatarUrl?: string
avatarUrl: string
// For their user page
bio?: string

View File

@ -6,7 +6,7 @@ export type OgCardProps = {
metadata: string
creatorName: string
creatorUsername: string
creatorAvatarUrl?: string
creatorAvatarUrl: string
}
function buildCardUrl(props: OgCardProps) {
@ -14,11 +14,6 @@ function buildCardUrl(props: OgCardProps) {
props.probability === undefined
? ''
: `&probability=${encodeURIComponent(props.probability ?? '')}`
const creatorAvatarUrlParam =
props.creatorAvatarUrl === undefined
? ''
: `&creatorAvatarUrl=${encodeURIComponent(props.creatorAvatarUrl ?? '')}`
// URL encode each of the props, then add them as query params
return (
`https://manifold-og-image.vercel.app/m.png` +
@ -26,7 +21,7 @@ function buildCardUrl(props: OgCardProps) {
probabilityParam +
`&metadata=${encodeURIComponent(props.metadata)}` +
`&creatorName=${encodeURIComponent(props.creatorName)}` +
creatorAvatarUrlParam +
`&creatorAvatarUrl=${encodeURIComponent(props.creatorAvatarUrl)}` +
`&creatorUsername=${encodeURIComponent(props.creatorUsername)}`
)
}

View File

@ -12,7 +12,7 @@ export type LiteMarket = {
creatorUsername: string
creatorName: string
createdTime: number
creatorAvatarUrl?: string
creatorAvatarUrl: string
// Market attributes. All times are in milliseconds since epoch
closeTime?: number