From 4de0fcd198b01354af1c7ec318c9729fdfbbe953 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Fri, 6 May 2022 14:29:15 -0400 Subject: [PATCH] Revert "Represent DB avatar URLs as non-null (#128)" This reverts commit bf8e09b6c1f2c5d1d9dcf672f210bba6d7a0a2e4. --- common/answer.ts | 2 +- common/comment.ts | 2 +- common/contract.ts | 2 +- common/user.ts | 2 +- web/components/SEO.tsx | 9 +++++++-- web/pages/api/v0/_types.ts | 2 +- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/common/answer.ts b/common/answer.ts index 87e7d05f..9dcc3828 100644 --- a/common/answer.ts +++ b/common/answer.ts @@ -9,7 +9,7 @@ export type Answer = { userId: string username: string name: string - avatarUrl: string + avatarUrl?: string text: string } diff --git a/common/comment.ts b/common/comment.ts index 95c2ec4a..15cfbcb5 100644 --- a/common/comment.ts +++ b/common/comment.ts @@ -13,5 +13,5 @@ export type Comment = { // Denormalized, for rendering comments userName: string userUsername: string - userAvatarUrl: string + userAvatarUrl?: string } diff --git a/common/contract.ts b/common/contract.ts index ee3034de..82a330b5 100644 --- a/common/contract.ts +++ b/common/contract.ts @@ -11,7 +11,7 @@ export type FullContract< creatorId: string creatorName: string creatorUsername: string - creatorAvatarUrl: string + creatorAvatarUrl?: string // Start requiring after 2022-03-01 question: string description: string // More info about what the contract is about diff --git a/common/user.ts b/common/user.ts index ce586774..8f8e6d0d 100644 --- a/common/user.ts +++ b/common/user.ts @@ -4,7 +4,7 @@ export type User = { name: string username: string - avatarUrl: string + avatarUrl?: string // For their user page bio?: string diff --git a/web/components/SEO.tsx b/web/components/SEO.tsx index 8420b199..8987d671 100644 --- a/web/components/SEO.tsx +++ b/web/components/SEO.tsx @@ -6,7 +6,7 @@ export type OgCardProps = { metadata: string creatorName: string creatorUsername: string - creatorAvatarUrl: string + creatorAvatarUrl?: string } function buildCardUrl(props: OgCardProps) { @@ -14,6 +14,11 @@ 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` + @@ -21,7 +26,7 @@ function buildCardUrl(props: OgCardProps) { probabilityParam + `&metadata=${encodeURIComponent(props.metadata)}` + `&creatorName=${encodeURIComponent(props.creatorName)}` + - `&creatorAvatarUrl=${encodeURIComponent(props.creatorAvatarUrl)}` + + creatorAvatarUrlParam + `&creatorUsername=${encodeURIComponent(props.creatorUsername)}` ) } diff --git a/web/pages/api/v0/_types.ts b/web/pages/api/v0/_types.ts index 4569576c..8f2976fa 100644 --- a/web/pages/api/v0/_types.ts +++ b/web/pages/api/v0/_types.ts @@ -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