2026-08-18 20:45:12 +07:00
|
|
|
import {
|
|
|
|
|
getConfig,
|
|
|
|
|
getGuilds,
|
|
|
|
|
getMessages,
|
|
|
|
|
getRecentEdits,
|
|
|
|
|
} from "@/lib/api/server";
|
2026-08-15 17:53:48 +07:00
|
|
|
import { MessagesView } from "./view";
|
2026-07-26 11:27:21 +07:00
|
|
|
|
2026-08-15 17:53:48 +07:00
|
|
|
export const dynamic = "force-dynamic";
|
2026-08-07 10:44:03 +07:00
|
|
|
|
2026-08-15 17:53:48 +07:00
|
|
|
export default async function MessagesPage() {
|
2026-08-15 20:03:55 +07:00
|
|
|
let config: import("@/lib/types/guild").AppConfig | undefined;
|
|
|
|
|
let guilds: import("@/lib/types").Guild[] | undefined;
|
2026-08-18 10:21:08 +07:00
|
|
|
let initialMessages: {
|
|
|
|
|
data: import("@/lib/types").MessageRecord[];
|
|
|
|
|
nextCursor: string | null;
|
|
|
|
|
} | null = null;
|
2026-08-18 20:45:12 +07:00
|
|
|
let initialEdits: import("@/lib/types").EditHistoryRow[] | undefined;
|
2026-08-15 17:53:48 +07:00
|
|
|
try {
|
|
|
|
|
[config, guilds] = await Promise.all([getConfig(), getGuilds()]);
|
2026-08-18 10:21:08 +07:00
|
|
|
const gid = config?.monitorGuildId;
|
|
|
|
|
if (gid) {
|
|
|
|
|
initialMessages = await getMessages(gid, undefined, 50);
|
|
|
|
|
}
|
2026-08-18 20:45:12 +07:00
|
|
|
initialEdits = await getRecentEdits(50);
|
2026-08-15 17:53:48 +07:00
|
|
|
} catch {
|
|
|
|
|
/* client hooks surface errors */
|
2026-08-07 10:44:03 +07:00
|
|
|
}
|
2026-08-15 20:03:55 +07:00
|
|
|
return (
|
2026-08-26 15:49:58 +07:00
|
|
|
<MessagesView
|
|
|
|
|
initialGuilds={guilds}
|
|
|
|
|
initialGuildId={config?.monitorGuildId ?? null}
|
|
|
|
|
initialMessages={initialMessages}
|
|
|
|
|
initialEdits={initialEdits}
|
|
|
|
|
/>
|
2026-08-15 20:03:55 +07:00
|
|
|
);
|
2026-07-26 11:27:21 +07:00
|
|
|
}
|