GeezerVison is showing github.com — fix(mobile): collapsed PR comments no longer cut an emoji in half (#4… · pingdotgg/t3code@024da4f
File tree
Expand file treeCollapse file tree
Open diff view settings
apps/mobile/src/features/pull-requests
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboard +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { expect, it } from "vite-plus/test"; |
| 2 | + |
| 3 | +import { collapsedTimelineCommentMarkdown } from "./PullRequestTimeline.logic"; |
| 4 | + |
| 5 | +it("keeps emoji whole at the collapsed comment preview limit", () => { |
| 6 | + const prefix = "a".repeat(1199); |
| 7 | + |
| 8 | + expect(collapsedTimelineCommentMarkdown(`${prefix}😀 trailing`)).toBe(prefix); |
| 9 | +}); |
Collapse file
Copy file name to clipboard +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { splitsSurrogatePair } from "@t3tools/shared/assistantCitations"; |
| 2 | + |
| 3 | +export function collapsedTimelineCommentMarkdown(body: string) { |
| 4 | + return body.slice(0, splitsSurrogatePair(body, 1200) ? 1199 : 1200); |
| 5 | +} |
Collapse file
Copy file name to clipboardExpand all lines: apps/mobile/src/features/pull-requests/PullRequestTimeline.tsx +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -22,6 +22,7 @@ import { byTimestamp, relativeTime } from "../../lib/time"; |
22 | 22 | import { PullRequestAvatar } from "./PullRequestPresentation"; |
23 | 23 | import { PullRequestMarkdown } from "./PullRequestMarkdown"; |
24 | 24 | import { PullRequestCommentFooter } from "./PullRequestReactions"; |
| 25 | +import { collapsedTimelineCommentMarkdown } from "./PullRequestTimeline.logic"; |
25 | 26 | import { pullRequestDescriptionContent } from "./pullRequestDescriptionContent"; |
26 | 27 | import { discussionCommentCountLabel } from "./pullRequestDiffComments"; |
27 | 28 | import { normalizedReviewState } from "./pullRequestStatus"; |
@@ -152,7 +153,9 @@ function TimelineComment({ |
152 | 153 | > |
153 | 154 | <View style={long && !expanded ? { maxHeight: 240, overflow: "hidden" } : undefined}> |
154 | 155 | <PullRequestMarkdown |
155 | | - markdown={long && !expanded ? comment.body.slice(0, 1200) : comment.body} |
| 156 | + markdown={ |
| 157 | + long && !expanded ? collapsedTimelineCommentMarkdown(comment.body) : comment.body |
| 158 | + } |
156 | 159 | imageGroupMarkdown={comment.body} |
157 | 160 | /> |
158 | 161 | </View> |
|