From 2273a7ac2975d9cddaf82771e35f76e20a59f0c1 Mon Sep 17 00:00:00 2001 From: Alejandro Gomez Date: Mon, 16 Jan 2023 00:45:23 +0100 Subject: [PATCH] dont pluralize when 1 more --- src/element/Note.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/element/Note.js b/src/element/Note.js index 7745ae2e..fc4a5af6 100644 --- a/src/element/Note.js +++ b/src/element/Note.js @@ -50,7 +50,8 @@ export default function Note(props) { let replyId = ev.Thread?.ReplyTo?.Event ?? ev.Thread?.Root?.Event; let mentions = ev.Thread?.PubKeys?.map(a => [a, users[a]])?.map(a => (a[1]?.name?.length ?? 0) > 0 ? a[1].name : hexToBech32("npub", a[0]).substring(0, 12)) .sort((a, b) => a.startsWith("npub") ? 1 : -1); - let pubMentions = mentions.length > maxMentions ? `${mentions?.slice(0, maxMentions).join(", ")} & ${mentions.length - maxMentions} others` : mentions?.join(", "); + let othersLength = mentions.length - maxMentions + let pubMentions = mentions.length > maxMentions ? `${mentions?.slice(0, maxMentions).join(", ")} & ${othersLength} other${othersLength > 1 ? 's' : ''}` : mentions?.join(", "); return (
➡️ {(pubMentions?.length ?? 0) > 0 ? pubMentions : hexToBech32("note", replyId)?.substring(0, 12)}