From 4b8c049a73d104bcc85ebd6c43568be16986d88b Mon Sep 17 00:00:00 2001 From: carrick Date: Wed, 3 Jan 2024 13:06:50 +0900 Subject: [PATCH] fix: handle nullable display_name --- src/components/common/FlatPostCard.tsx | 4 +++- src/components/common/PostCard.tsx | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/common/FlatPostCard.tsx b/src/components/common/FlatPostCard.tsx index e57e07fa..77db98bb 100644 --- a/src/components/common/FlatPostCard.tsx +++ b/src/components/common/FlatPostCard.tsx @@ -170,7 +170,9 @@ const FlatPostCard = ({ post, hideUser }: PostCardProps) => { />
- {post.user.profile.display_name} + + {post.user?.profile?.display_name ?? post.user.username} +
)} diff --git a/src/components/common/PostCard.tsx b/src/components/common/PostCard.tsx index f4f6a8eb..1befe891 100644 --- a/src/components/common/PostCard.tsx +++ b/src/components/common/PostCard.tsx @@ -83,7 +83,7 @@ function PostCard({ post, forHome, forPost }: PostCardProps) { alt={`user thumbnail of ${post.user.username}`} /> - by {post.user.profile.display_name} + by {post.user?.profile?.display_name ?? post.user.username}