Skip to content

Commit

Permalink
Don't show replies twice when viewing source with legacy replies
Browse files Browse the repository at this point in the history
  • Loading branch information
mybearworld committed Jul 21, 2024
1 parent ef7f9d7 commit 30dfbd7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const PostBase = memo((props: PostBaseProps) => {
ids: props.post.reply_to,
postContent: props.post.p,
replyText: "",
legacy: false,
} satisfies PostWithReplies)
: getReply(props.post.p);

Expand Down Expand Up @@ -286,7 +287,11 @@ const PostBase = memo((props: PostBaseProps) => {
Couldn't delete post. Message: {deleteError}
</div>
: undefined}
{!props.reply && reply?.ids ?
{(
!props.reply &&
reply?.ids &&
!(viewState === "source" && reply?.legacy)
) ?
<div className="my-1 flex flex-col gap-2">
{reply.ids.map((id) => (
<Post id={id} reply key={id} />
Expand Down
2 changes: 2 additions & 0 deletions src/lib/reply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type PostWithReplies = {
ids: string[];
postContent: string;
replyText: string;
legacy: boolean;
};
export const getReply = (post: string): PostWithReplies | null => {
const match = post.match(REPLY_REGEX);
Expand All @@ -28,6 +29,7 @@ export const getReply = (post: string): PostWithReplies | null => {
ids: [id, ...(subReply?.ids ?? [])],
postContent: subReply?.postContent ?? postContent,
replyText: subReply ? replyText + subReply.replyText : replyText,
legacy: true
};
};

Expand Down

0 comments on commit 30dfbd7

Please sign in to comment.