fix: refresh shared page author avatar
This commit is contained in:
+10
-8
@@ -12,7 +12,6 @@ import {
|
||||
DeleteShareButton,
|
||||
} from "@/app/share/[id]/share-client";
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
@@ -32,6 +31,7 @@ import { Separator } from "@/components/ui/separator";
|
||||
import { authOptions } from "@/lib/auth/auth-options";
|
||||
import { getAdminDiscordIds, getSessionDiscordId } from "@/lib/auth/auth";
|
||||
import { cdnUrl } from "@/lib/cdn-images";
|
||||
import { getDiscordMemberProfile } from "@/lib/discord/discord";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -81,6 +81,11 @@ export default async function SharedTextPage({
|
||||
.limit(1);
|
||||
if (!share) notFound();
|
||||
|
||||
const authorProfile = await getDiscordMemberProfile(
|
||||
share.authorDiscordId,
|
||||
);
|
||||
const authorAvatarUrl = authorProfile?.avatarUrl || share.authorAvatarUrl;
|
||||
|
||||
const requestedSort = Array.isArray(query.comments)
|
||||
? query.comments[0]
|
||||
: query.comments;
|
||||
@@ -118,11 +123,11 @@ export default async function SharedTextPage({
|
||||
<div className="flex flex-col gap-6">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex flex-wrap items-start justify-between gap-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex min-w-0 items-center gap-3">
|
||||
<Avatar size="lg">
|
||||
{share.authorAvatarUrl && (
|
||||
<AvatarImage src={share.authorAvatarUrl} alt={share.authorName} />
|
||||
{authorAvatarUrl && (
|
||||
<AvatarImage src={authorAvatarUrl} alt={share.authorName} />
|
||||
)}
|
||||
<AvatarFallback>{initials(share.authorName)}</AvatarFallback>
|
||||
</Avatar>
|
||||
@@ -131,13 +136,10 @@ export default async function SharedTextPage({
|
||||
{share.authorName}
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
{formatBangkok(share.createdAt)} น. · เวลาไทย
|
||||
{formatBangkok(share.createdAt)} น.
|
||||
</CardDescription>
|
||||
</div>
|
||||
</div>
|
||||
<Badge variant="outline" className="font-mono">
|
||||
{share.source === "bot" ? "Discord bot" : "Web"} · {share.id}
|
||||
</Badge>
|
||||
</div>
|
||||
</CardHeader>
|
||||
{(share.description || share.imageCdnId) && (
|
||||
|
||||
Reference in New Issue
Block a user