feat: add author display name to thought schemas and update related components
This commit is contained in:
@@ -44,6 +44,7 @@ interface ThoughtCardProps {
|
||||
thought: Thought;
|
||||
author: {
|
||||
username: string;
|
||||
displayName?: string | null;
|
||||
avatarUrl?: string | null;
|
||||
};
|
||||
currentUser: Me | null;
|
||||
@@ -112,9 +113,14 @@ export function ThoughtCard({
|
||||
href={`/users/${author.username}`}
|
||||
className="flex items-center gap-4 text-shadow-md"
|
||||
>
|
||||
<UserAvatar src={author.avatarUrl} alt={author.username} />
|
||||
<UserAvatar
|
||||
src={author.avatarUrl}
|
||||
alt={author.displayName || author.username}
|
||||
/>
|
||||
<div className="flex flex-col">
|
||||
<span className="font-bold">{author.username}</span>
|
||||
<span className="font-bold">
|
||||
{author.displayName || author.username}
|
||||
</span>
|
||||
<span className="text-sm text-muted-foreground text-shadow-sm">
|
||||
{timeAgo}
|
||||
</span>
|
||||
|
@@ -28,7 +28,7 @@ export function ThoughtList({
|
||||
{thoughts.map((thought) => {
|
||||
const author = {
|
||||
username: thought.authorUsername,
|
||||
avatarUrl: null,
|
||||
displayName: thought.authorDisplayName,
|
||||
...authorDetails.get(thought.authorUsername),
|
||||
};
|
||||
return (
|
||||
|
@@ -16,7 +16,7 @@ export function ThoughtThread({
|
||||
}: ThoughtThreadProps) {
|
||||
const author = {
|
||||
username: thought.authorUsername,
|
||||
avatarUrl: null,
|
||||
displayName: thought.authorDisplayName,
|
||||
...authorDetails.get(thought.authorUsername),
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ export function ThoughtThread({
|
||||
className="pl-6 border-l-2 border-primary border-dashed ml-6 flex flex-col gap-4 pt-4"
|
||||
>
|
||||
{thought.replies.map((reply) => (
|
||||
<ThoughtThread // RECURSIVE CALL
|
||||
<ThoughtThread
|
||||
key={reply.id}
|
||||
thought={reply}
|
||||
authorDetails={authorDetails}
|
||||
|
@@ -28,6 +28,7 @@ export const MeSchema = z.object({
|
||||
export const ThoughtSchema = z.object({
|
||||
id: z.uuid(),
|
||||
authorUsername: z.string(),
|
||||
authorDisplayName: z.string().nullable(),
|
||||
content: z.string(),
|
||||
visibility: z.enum(["Public", "FriendsOnly", "Private"]),
|
||||
replyToId: z.uuid().nullable(),
|
||||
@@ -87,6 +88,7 @@ export const CreateApiKeySchema = z.object({
|
||||
export const ThoughtThreadSchema: z.ZodType<{
|
||||
id: string;
|
||||
authorUsername: string;
|
||||
authorDisplayName: string | null;
|
||||
content: string;
|
||||
visibility: "Public" | "FriendsOnly" | "Private";
|
||||
replyToId: string | null;
|
||||
@@ -95,6 +97,7 @@ export const ThoughtThreadSchema: z.ZodType<{
|
||||
}> = z.object({
|
||||
id: z.uuid(),
|
||||
authorUsername: z.string(),
|
||||
authorDisplayName: z.string().nullable(),
|
||||
content: z.string(),
|
||||
visibility: z.enum(["Public", "FriendsOnly", "Private"]),
|
||||
replyToId: z.uuid().nullable(),
|
||||
|
Reference in New Issue
Block a user