33 lines
904 B
TypeScript
33 lines
904 B
TypeScript
|
import { Handlers, PageProps } from "$fresh/server.ts";
|
||
|
import { Database, Option } from "types";
|
||
|
import { get_db_obj } from "db";
|
||
|
import Conv from "components/Conv.tsx";
|
||
|
|
||
|
export const handler: Handlers<Option<Database>> = {
|
||
|
async GET(req, ctx) {
|
||
|
const db = await get_db_obj();
|
||
|
if (
|
||
|
db.isNone() ||
|
||
|
!db.unwrap().conversations[ctx.params.conversation_id]
|
||
|
) {
|
||
|
return ctx.renderNotFound();
|
||
|
}
|
||
|
return ctx.render(db);
|
||
|
},
|
||
|
};
|
||
|
|
||
|
export default function ConversationPreview({
|
||
|
data,
|
||
|
params,
|
||
|
}: PageProps<Option<Database>>) {
|
||
|
if (
|
||
|
data.isSome() &&
|
||
|
params.conversation_id &&
|
||
|
data.unwrap().conversations[params.conversation_id]
|
||
|
) {
|
||
|
return <Conv conv={params.conversation_id} db={data.unwrap()} />;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//TODO: keyboard shortcut (advertised elsewhere) that activates interactive mode
|