💾 Archived View for iich.space › src › views › ThreadPage.ts captured on 2022-03-01 at 16:00:50.

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

import { Template } from '@/mission-control';

import { Board, BoardType, ThreadWithReplies } from '~/db/models';
import { IdentityDisplay } from '~/util/identity';

import Header from './Header';
import PostItem from './PostItem';

interface Props {
  board: Board;
  thread: ThreadWithReplies;
  identity: IdentityDisplay | null;
}

const ThreadPage: Template<Props> = (
  { each, include, link, t, when },
  { board, identity, thread },
): string => `
${include(Header, { board })}

${link(board.path, t('return'))}

${include(PostItem, { post: thread, showLinks: true })}
${when(
  thread.replies.length > 0,
  () => `

${when(
  thread.replies.length < thread.replyCount,
  () => `
${link(`${thread.path}/full`, '...')}

`,
)}
${each(
  thread.replies,
  (post) => include(PostItem, { post, showLinks: true }),
  2,
)}
`,
)}

${when(
  thread.locked !== 1,
  () => `
${link(`${thread.path}/post`, t('post_reply'))}
${when(
  identity !== null,
  () => `
${link(`${thread.path}/post?signed`, t('post_reply_as', identity!.display))}
`,
)}
${when(
  board.type === BoardType.Image,
  () => `
${link(`${thread.path}/post?image`, t('post_image_reply'))}
${when(
  identity !== null,
  () => `
${link(
  `${thread.path}/post?signed,image`,
  t('post_image_reply_as', identity!.display),
)}
`,
)}
`,
)}
`,
  () => `
${t('thread_locked')}
`,
)}
`;

export default ThreadPage;