2026-08-07 10:44:03 +07:00
|
|
|
/**
|
2026-08-14 10:49:44 +07:00
|
|
|
* Messages — Server Component.
|
|
|
|
|
* Reads URL guild/channel/selected/tab on the server; seeds first page SSR.
|
2026-08-07 10:44:03 +07:00
|
|
|
*/
|
2026-08-14 11:02:52 +07:00
|
|
|
import { getMessages, type MessagePageResult } from "@/lib/api/server";
|
2026-08-07 10:44:03 +07:00
|
|
|
import MessagesView from "./view";
|
2026-07-26 11:27:21 +07:00
|
|
|
|
2026-08-07 10:44:03 +07:00
|
|
|
export default async function MessagesPage({
|
|
|
|
|
searchParams,
|
2026-07-28 10:42:12 +07:00
|
|
|
}: {
|
2026-08-07 10:44:03 +07:00
|
|
|
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
2026-07-28 10:42:12 +07:00
|
|
|
}) {
|
2026-08-07 10:44:03 +07:00
|
|
|
const sp = await searchParams;
|
|
|
|
|
const guild = typeof sp.guild === "string" ? sp.guild : "";
|
|
|
|
|
const channel = typeof sp.channel === "string" ? sp.channel : "";
|
|
|
|
|
const selected = typeof sp.selected === "string" ? sp.selected : null;
|
|
|
|
|
const tab =
|
|
|
|
|
typeof sp.tab === "string" && ["all", "images", "review"].includes(sp.tab)
|
|
|
|
|
? (sp.tab as "all" | "images" | "review")
|
|
|
|
|
: "all";
|
|
|
|
|
|
2026-08-14 11:02:52 +07:00
|
|
|
let initialPage: MessagePageResult | undefined;
|
2026-08-07 10:44:03 +07:00
|
|
|
if (guild) {
|
|
|
|
|
initialPage = await getMessages(guild, channel || undefined).catch(
|
|
|
|
|
() => undefined,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-28 10:05:08 +07:00
|
|
|
return (
|
2026-08-07 10:44:03 +07:00
|
|
|
<MessagesView
|
|
|
|
|
initialGuild={guild}
|
|
|
|
|
initialChannel={channel}
|
|
|
|
|
initialDetailId={selected}
|
|
|
|
|
initialTab={tab}
|
|
|
|
|
initialMessagePage={initialPage}
|
|
|
|
|
/>
|
2026-07-26 11:27:21 +07:00
|
|
|
);
|
|
|
|
|
}
|