fix(feed): don't count inline media URLs toward the long-post threshold#406
Open
dmnyc wants to merge 1 commit into
Open
fix(feed): don't count inline media URLs toward the long-post threshold#406dmnyc wants to merge 1 commit into
dmnyc wants to merge 1 commit into
Conversation
A note with a short caption and an image gallery was collapsed behind a "Show more" toggle with a large empty gap, because charLong measured raw content.count — which includes the inline image URLs that render as the gallery, not as text. A 4-line caption plus five ~90-char .png URLs tripped the 600-char threshold. Add ContentParser.textualLength(content:tags:), which sums only the text-bearing segments (.text / .hashtag / .inlineLink) and excludes media, standalone link cards, quote cards, and invoices. charLong now requires both the raw count and the text-only length to exceed the threshold; the raw-count guard keeps the extra parse off the hot path for short posts. Genuinely long text posts still collapse; the measured-height (pixelLong) path is unchanged. Fixes #405
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A note with a short caption and an image gallery was collapsed behind a "Show more" toggle, with a large empty gap between the caption and the toggle — even though the actual text was only a few lines.
Root cause
PostCardView's long-post decision isisLong = pixelLong || charLong, wherecharLong = displayEvent.content.count > 600. That counts the raw content string, including inline media URLs. The repro note is 659 chars, but ~496 of those are five inline.pngimage URLs (~90 chars each) that render as the gallery, not as text — the caption is only ~163 chars / 4 lines.charLongtripped, the post was collapsed with the 280pt text cap, and since the text is far shorter than 280pt the frame left a big empty gap above "Show more".Fix
ContentParser.textualLength(content:tags:)— sums only the text-bearing segments (.text,.hashtag,.inlineLink), excluding media, standalone link-preview cards, embedded quote cards, and lightning-invoice cards.charLongnow requires both the raw count and the text-only length to exceed 600. The raw-count guard keeps the extra parse off the hot path for short posts.pixelLong) path is unchanged.Fixes #405.
Before / After
Test plan