(props: { postId: string })
| 12 | import { Link } from './ui/link'; |
| 13 | |
| 14 | export const FeedPost = async (props: { postId: string }) => { |
| 15 | const result = await messages.load(props.postId); |
| 16 | if (!result) return null; |
| 17 | const { message: rootOrComment, channel: thread, parent, server } = result; |
| 18 | if ( |
| 19 | !rootOrComment || |
| 20 | !rootOrComment.parentChannelId || |
| 21 | !rootOrComment.public || |
| 22 | server.kickedTime |
| 23 | ) |
| 24 | return null; |
| 25 | |
| 26 | const root = |
| 27 | rootOrComment.id !== thread.id |
| 28 | ? await findMessageByIdWithDiscordAccount(thread.id) |
| 29 | : rootOrComment; |
| 30 | if (!root || !root.public) return null; |
| 31 | const comment = rootOrComment.id !== thread.id ? rootOrComment : null; |
| 32 | |
| 33 | const count = await channelCountsLoader.load(thread.id); |
| 34 | |
| 35 | const focused = comment ?? root; |
| 36 | const discordMarkdownAsHTML = await parse(focused.content); |
| 37 | const firstImage = focused.attachments.filter(isImageAttachment).at(0); |
| 38 | |
| 39 | const MainContent = () => ( |
| 40 | <div className={'inner'}> |
| 41 | <div className="flex flex-col items-start gap-2 pb-2 text-xs sm:flex-row sm:items-center md:text-base"> |
| 42 | <Link |
| 43 | href={`/c/${server.id}`} |
| 44 | className={'flex items-center gap-2 hover:underline'} |
| 45 | > |
| 46 | <ServerIcon server={server} size={24} /> |
| 47 | <span>{server.name}</span> |
| 48 | </Link> |
| 49 | <div className={'flex flex-col gap-2 md:flex-row'}> |
| 50 | <span className={'hidden text-sm text-muted-foreground md:block'}> |
| 51 | • |
| 52 | </span> |
| 53 | <span className={'text-sm text-muted-foreground'}> |
| 54 | Created by {root.author.name} on {getSnowflakeUTCDate(root.id)} in{' '} |
| 55 | <Link |
| 56 | className={'hover:underline'} |
| 57 | href={`/c/${server.id}/${parent.id}`} |
| 58 | > |
| 59 | #{parent.name} |
| 60 | </Link> |
| 61 | </span> |
| 62 | </div> |
| 63 | </div> |
| 64 | <div className={'pb-2 font-semibold'}> |
| 65 | <span className={'text-lg'}>{thread.name}</span> |
| 66 | </div> |
| 67 | <div |
| 68 | className={ |
| 69 | 'max-h-[300px] overflow-hidden whitespace-break-spaces font-body text-primary' |
| 70 | } |
| 71 | > |
nothing calls this directly
no test coverage detected