From e2cf48eed9bdc76f62eea996fe917e6b79230ad7 Mon Sep 17 00:00:00 2001 From: Jonathan Staab Date: Mon, 19 Jun 2023 09:05:11 -0700 Subject: [PATCH] Fix ellipsis placement --- src/util/notes.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/util/notes.ts b/src/util/notes.ts index 778fa1bf..322b1838 100644 --- a/src/util/notes.ts +++ b/src/util/notes.ts @@ -169,7 +169,7 @@ export const truncateContent = (content, {showEntire, maxLength, showMedia = fal const result = [] const truncateAt = maxLength * 0.6 - for (const part of content) { + content.every((part, i) => { const isText = [TOPIC, TEXT].includes(part.type) const isMedia = [LINK, INVOICE].includes(part.type) || part.type.startsWith("nostr:") @@ -183,14 +183,16 @@ export const truncateContent = (content, {showEntire, maxLength, showMedia = fal result.push(part) - if (length > truncateAt) { + if (length > truncateAt && i < content.length - 1) { if (isText || (isMedia && !showMedia)) { result.push({type: TEXT, value: "..."}) } - break + return false } - } + + return true + }) return result }