mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-03-26 17:52:18 +01:00
small fix for subject heading
This commit is contained in:
parent
5f9c96e744
commit
db16d6bbe3
@ -1,5 +1,6 @@
|
||||
import { validateEvent } from "nostr-tools";
|
||||
import { NostrEvent, isDTag, isETag, isPTag } from "../../types/nostr-event";
|
||||
import { getMatchLink, getMatchNostrLink } from "../regexp";
|
||||
|
||||
export const SUBSCRIBED_COMMUNITIES_LIST_IDENTIFIER = "communities";
|
||||
export const COMMUNITY_DEFINITION_KIND = 34550;
|
||||
@ -30,7 +31,11 @@ export function getCommunityRules(community: NostrEvent) {
|
||||
}
|
||||
|
||||
export function getPostSubject(event: NostrEvent) {
|
||||
return event.tags.find((t) => t[0] === "subject")?.[1] || event.content.match(/^[^\n\t]+/);
|
||||
const subject = event.tags.find((t) => t[0] === "subject")?.[1];
|
||||
if (subject) return subject;
|
||||
const firstLine = event.content.match(/^[^\n\t]+/)?.[0];
|
||||
if (!firstLine) return;
|
||||
if (!getMatchNostrLink().test(firstLine) && !getMatchLink().test(firstLine)) return firstLine;
|
||||
}
|
||||
|
||||
export function getApprovedEmbeddedNote(approval: NostrEvent) {
|
||||
|
@ -52,18 +52,24 @@ const ApprovedEvent = memo(
|
||||
[navigate, to],
|
||||
);
|
||||
|
||||
const subject = getPostSubject(event);
|
||||
|
||||
return (
|
||||
<Flex ref={ref} gap="2" alignItems="flex-start" overflow="hidden">
|
||||
<PostVoteButtons event={event} community={community} />
|
||||
<Flex gap="2" direction="column" flex={1}>
|
||||
<Card as={LinkBox}>
|
||||
<CardHeader px="2" pt="4" pb="0">
|
||||
<Heading size="md">
|
||||
<HoverLinkOverlay as={RouterLink} to={to} onClick={handleClick}>
|
||||
{getPostSubject(event)}
|
||||
</HoverLinkOverlay>
|
||||
</Heading>
|
||||
</CardHeader>
|
||||
<Flex gap="2" direction="column" flex={1} overflow="hidden">
|
||||
<Card as={LinkBox} overflow="hidden">
|
||||
{subject ? (
|
||||
<CardHeader px="2" pt="4" pb="0" overflow="hidden">
|
||||
<Heading size="md" overflow="hidden" isTruncated>
|
||||
<HoverLinkOverlay as={RouterLink} to={to} onClick={handleClick}>
|
||||
{getPostSubject(event)}
|
||||
</HoverLinkOverlay>
|
||||
</Heading>
|
||||
</CardHeader>
|
||||
) : (
|
||||
<HoverLinkOverlay as={RouterLink} to={to} onClick={handleClick} />
|
||||
)}
|
||||
<CardBody p="2">
|
||||
<InlineNoteContent event={event} maxLength={96} />
|
||||
</CardBody>
|
||||
|
Loading…
x
Reference in New Issue
Block a user