Skip to content

Commit f1ee555

Browse files
authored
fix: render post title markdown in inbox (#2065)
1 parent 8f64f98 commit f1ee555

File tree

7 files changed

+29
-19
lines changed

7 files changed

+29
-19
lines changed

src/features/inbox/InboxItem.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import CommentMarkdown from "#/features/comment/CommentMarkdown";
1212
import Ago from "#/features/labels/Ago";
1313
import CommunityLink from "#/features/labels/links/CommunityLink";
1414
import PersonLink from "#/features/labels/links/PersonLink";
15+
import PostTitleMarkdown from "#/features/shared/markdown/PostTitleMarkdown";
1516
import SlidingInbox from "#/features/shared/sliding/SlidingInbox";
1617
import { cx } from "#/helpers/css";
1718
import { isTouchDevice } from "#/helpers/device";
@@ -64,7 +65,9 @@ export default function InboxItem({ item }: InboxItemProps) {
6465
return (
6566
<>
6667
<strong>{item.creator.name}</strong> mentioned you on the post{" "}
67-
<strong>{item.post.name}</strong>
68+
<strong>
69+
<PostTitleMarkdown>{item.post.name}</PostTitleMarkdown>
70+
</strong>
6871
</>
6972
);
7073
}
@@ -73,14 +76,18 @@ export default function InboxItem({ item }: InboxItemProps) {
7376
return (
7477
<>
7578
<strong>{item.creator.name}</strong> replied to your post{" "}
76-
<strong>{item.post.name}</strong>
79+
<strong>
80+
<PostTitleMarkdown>{item.post.name}</PostTitleMarkdown>
81+
</strong>
7782
</>
7883
);
7984
} else {
8085
return (
8186
<>
8287
<strong>{item.creator.name}</strong> replied to your comment in{" "}
83-
<strong>{item.post.name}</strong>
88+
<strong>
89+
<PostTitleMarkdown>{item.post.name}</PostTitleMarkdown>
90+
</strong>
8491
</>
8592
);
8693
}

src/features/post/detail/PostHeader.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import PostLink from "#/features/post/link/PostLink";
1818
import { togglePostCollapse } from "#/features/post/postSlice";
1919
import useCrosspostUrl from "#/features/post/shared/useCrosspostUrl";
2020
import useIsPostUrlMedia from "#/features/post/useIsPostUrlMedia";
21-
import InlineMarkdown from "#/features/shared/markdown/InlineMarkdown";
2221
import Markdown from "#/features/shared/markdown/Markdown";
22+
import PostTitleMarkdown from "#/features/shared/markdown/PostTitleMarkdown";
2323
import { cx } from "#/helpers/css";
2424
import { findIonContentScrollView } from "#/helpers/ionic";
2525
import { postLocked } from "#/helpers/toastMessages";
@@ -177,9 +177,7 @@ export default function PostHeader({
177177
<ModeratableItemBannerOutlet />
178178
<div>
179179
<div className={styles.title} ref={titleRef}>
180-
<InlineMarkdown parseBlocks={false}>
181-
{post.post.name}
182-
</InlineMarkdown>{" "}
180+
<PostTitleMarkdown>{post.post.name}</PostTitleMarkdown>{" "}
183181
{isNsfw(post) && <Nsfw />}
184182
</div>
185183
{showPostText && text && (

src/features/post/inFeed/compact/CompactPost.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import MoreActions from "#/features/post/shared/MoreActions";
1616
import MoreModActions from "#/features/post/shared/MoreModAction";
1717
import useCrosspostUrl from "#/features/post/shared/useCrosspostUrl";
1818
import { VoteButton } from "#/features/post/shared/VoteButton";
19-
import InlineMarkdown from "#/features/shared/markdown/InlineMarkdown";
19+
import PostTitleMarkdown from "#/features/shared/markdown/PostTitleMarkdown";
2020
import { cx, sv } from "#/helpers/css";
2121
import { isUrlImage, parseUrlForDisplay } from "#/helpers/url";
2222
import { useInModqueue } from "#/routes/pages/shared/ModqueuePage";
@@ -76,9 +76,7 @@ export default function CompactPost({ post }: PostProps) {
7676
</div>
7777
)}
7878
<span className={styles.title}>
79-
<InlineMarkdown parseBlocks={false}>
80-
{post.post.name}
81-
</InlineMarkdown>{" "}
79+
<PostTitleMarkdown>{post.post.name}</PostTitleMarkdown>{" "}
8280
{domain && (
8381
<>
8482
<span className={styles.domain}>

src/features/post/inFeed/large/LargePost.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import MoreActions from "#/features/post/shared/MoreActions";
1515
import MoreModActions from "#/features/post/shared/MoreModAction";
1616
import useCrosspostUrl from "#/features/post/shared/useCrosspostUrl";
1717
import { VoteButton } from "#/features/post/shared/VoteButton";
18-
import InlineMarkdown from "#/features/shared/markdown/InlineMarkdown";
18+
import PostTitleMarkdown from "#/features/shared/markdown/PostTitleMarkdown";
1919
import { cx } from "#/helpers/css";
2020
import { useInModqueue } from "#/routes/pages/shared/ModqueuePage";
2121
import { useAppSelector } from "#/store";
@@ -82,9 +82,7 @@ export default function LargePost({ post }: PostProps) {
8282
)}
8383

8484
<div className={styles.title}>
85-
<InlineMarkdown parseBlocks={false}>
86-
{post.post.name}
87-
</InlineMarkdown>{" "}
85+
<PostTitleMarkdown>{post.post.name}</PostTitleMarkdown>{" "}
8886
{isNsfw(post) && <Nsfw />}
8987
</div>
9088
</div>

src/features/post/link/Link.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { MouseEvent, useEffect, useState } from "react";
44

55
import { LinkData } from "#/features/comment/CommentLinks";
66
import CachedImg from "#/features/media/CachedImg";
7-
import InlineMarkdown from "#/features/shared/markdown/InlineMarkdown";
87
import LinkInterceptor from "#/features/shared/markdown/LinkInterceptor";
8+
import PostTitleMarkdown from "#/features/shared/markdown/PostTitleMarkdown";
99
import Url from "#/features/shared/Url";
1010
import useLemmyUrlHandler from "#/features/shared/useLemmyUrlHandler";
1111
import { cx } from "#/helpers/css";
@@ -164,7 +164,7 @@ export default function Link({
164164
{buildCompactIcon()}
165165
<div className={styles.urlContainer}>
166166
<div className={styles.text}>
167-
<InlineMarkdown parseBlocks={false}>{text ?? ""}</InlineMarkdown>
167+
<PostTitleMarkdown>{text ?? ""}</PostTitleMarkdown>
168168
</div>
169169
<Url>{url}</Url>
170170
</div>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ComponentProps } from "react";
2+
3+
import InlineMarkdown from "./InlineMarkdown";
4+
5+
export default function PostTitleMarkdown(
6+
props: ComponentProps<typeof InlineMarkdown>,
7+
) {
8+
return <InlineMarkdown {...props} parseBlocks={false} />;
9+
}

src/features/user/PostContext.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Link } from "react-router-dom";
22
import { Community, Post } from "threadiverse";
33

4-
import InlineMarkdown from "#/features/shared/markdown/InlineMarkdown";
4+
import PostTitleMarkdown from "#/features/shared/markdown/PostTitleMarkdown";
55
import { getHandle } from "#/helpers/lemmy";
66
import { useOpenPostInSecondColumnIfNeededProps } from "#/routes/twoColumn/useOpenInSecondColumnIfNeededProps";
77

@@ -30,7 +30,7 @@ export default function PostContext({ post, community }: PostContextProps) {
3030
}}
3131
>
3232
<div className={styles.name}>
33-
<InlineMarkdown parseBlocks={false}>{post.name}</InlineMarkdown>
33+
<PostTitleMarkdown>{post.name}</PostTitleMarkdown>
3434
</div>
3535
<div className={styles.communityName}>{getHandle(community)}</div>
3636
</Link>

0 commit comments

Comments
 (0)