Fix custom emoji reactions having multiple colons

This commit is contained in:
hzrd149
2024-03-08 12:20:26 +00:00
parent 0d5ce89ead
commit a967cc834c
5 changed files with 14 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
"nostrudel": patch
---
Fix custom emoji reactions having multiple colons

View File

@@ -46,7 +46,7 @@ export default function EmbeddedEmojiPack({ pack, ...props }: Omit<CardProps, "c
{emojis.length > 0 && (
<Flex mb="2" wrap="wrap" gap="2">
{emojis.map(({ name, url }) => (
<Image key={name + url} src={url} title={name} alt={`:${name}:`} w={8} h={8} />
<Image key={name + url} src={url} title={name} alt={`:${name}:`} w={8} h={8} overflow="hidden" />
))}
</Flex>
)}

View File

@@ -17,7 +17,8 @@ export function embedEmoji(content: EmbedableContent, note: NostrEvent | DraftNo
display="inline-block"
verticalAlign="middle"
title={match[1]}
alt={match[1]}
alt={":" + match[1] + ":"}
overflow="hidden"
/>
);
}

View File

@@ -4,6 +4,6 @@ import { DislikeIcon, LikeIcon } from "../icons";
export default function ReactionIcon({ emoji, url }: { emoji: string; url?: string }) {
if (emoji === "+") return <LikeIcon />;
if (emoji === "-") return <DislikeIcon />;
if (url) return <Image src={url} title={emoji} alt={emoji} w="1em" h="1em" display="inline" />;
if (url) return <Image src={url} title={emoji} alt={emoji} w="1em" h="1em" display="inline" overflow="hidden" />;
return <span>{emoji}</span>;
}

View File

@@ -26,9 +26,13 @@ export function draftEventReaction(event: NostrEvent, emoji = "+", url?: string)
["e", event.id],
["p", event.pubkey],
];
let content = emoji;
if (url && !content.startsWith(":") && content.endsWith(":")) content = ":" + content + ":";
const draft: DraftNostrEvent = {
kind: kinds.Reaction,
content: url ? ":" + emoji + ":" : emoji,
content,
tags: isReplaceable(event.kind) ? [...tags, ["a", getEventCoordinate(event)]] : tags,
created_at: dayjs().unix(),
};