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

View Raw

More Information

⬅️ Previous capture (2021-12-03)

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

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

import { ThreadWithReplies } from '~/db/models';

import PostItem from './PostItem';

interface Props {
  thread: ThreadWithReplies;
  repliesPerThread: number;
  showLinks?: boolean;
}

const ThreadItem: Template<Props> = (
  { each, include, t, when },
  { repliesPerThread, showLinks, thread },
): string => `
=> ${thread.path} ${include(PostItem, { post: thread, showLinks })}
${when(
  thread.replies.length > 0,
  () => `

${when(
  thread.replyCount > repliesPerThread,
  () => `
...

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

=> ${thread.path} ${t('reply')}
`;

export default ThreadItem;