Skip to content

Commit

Permalink
refactor: Update PostMention type handling in fragments and components
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Mar 2, 2025
1 parent 026c522 commit 2c45f64
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Markup from "@components/Shared/Markup";
import { ChatBubbleLeftIcon } from "@heroicons/react/24/outline";
import getPostData from "@hey/helpers/getPostData";
import type { CommentNotificationFragment, PostMention } from "@hey/indexer";
import type { CommentNotificationFragment } from "@hey/indexer";
import Link from "next/link";
import type { FC } from "react";
import { NotificationAccountAvatar } from "../Account";
Expand Down Expand Up @@ -41,7 +41,7 @@ const CommentNotification: FC<CommentNotificationProps> = ({
className="ld-text-gray-500 linkify mt-2 line-clamp-2"
href={`/posts/${notification.comment.id}`}
>
<Markup mentions={notification.comment.mentions as PostMention[]}>
<Markup mentions={notification.comment.mentions}>
{filteredContent}
</Markup>
</Link>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Markup from "@components/Shared/Markup";
import { AtSymbolIcon } from "@heroicons/react/24/outline";
import getPostData from "@hey/helpers/getPostData";
import type { MentionNotificationFragment, PostMention } from "@hey/indexer";
import type { MentionNotificationFragment } from "@hey/indexer";
import Link from "next/link";
import type { FC } from "react";
import { NotificationAccountAvatar } from "../Account";
Expand Down Expand Up @@ -40,7 +40,7 @@ const MentionNotification: FC<MentionNotificationProps> = ({
className="ld-text-gray-500 linkify mt-2 line-clamp-2"
href={`/posts/${notification.post.id}`}
>
<Markup mentions={notification.post.mentions as PostMention[]}>
<Markup mentions={notification.post.mentions}>
{filteredContent}
</Markup>
</Link>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Markup from "@components/Shared/Markup";
import { ChatBubbleBottomCenterTextIcon } from "@heroicons/react/24/outline";
import getPostData from "@hey/helpers/getPostData";
import type { PostMention, QuoteNotificationFragment } from "@hey/indexer";
import type { QuoteNotificationFragment } from "@hey/indexer";
import Link from "next/link";
import type { FC } from "react";
import { NotificationAccountAvatar } from "../Account";
Expand Down Expand Up @@ -38,7 +38,7 @@ const QuoteNotification: FC<QuoteNotificationProps> = ({ notification }) => {
className="ld-text-gray-500 linkify mt-2 line-clamp-2"
href={`/posts/${notification.quote.id}`}
>
<Markup mentions={notification.quote.mentions as PostMention[]}>
<Markup mentions={notification.quote.mentions}>
{filteredContent}
</Markup>
</Link>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Markup from "@components/Shared/Markup";
import { HeartIcon } from "@heroicons/react/24/outline";
import getPostData from "@hey/helpers/getPostData";
import type { PostMention, ReactionNotificationFragment } from "@hey/indexer";
import type { ReactionNotificationFragment } from "@hey/indexer";
import Link from "next/link";
import plur from "plur";
import type { FC } from "react";
Expand Down Expand Up @@ -50,7 +50,7 @@ const ReactionNotification: FC<ReactionNotificationProps> = ({
className="ld-text-gray-500 linkify mt-2 line-clamp-2"
href={`/posts/${notification.post.id}`}
>
<Markup mentions={notification.post.mentions as PostMention[]}>
<Markup mentions={notification.post.mentions}>
{filteredContent}
</Markup>
</Link>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Markup from "@components/Shared/Markup";
import { ArrowsRightLeftIcon } from "@heroicons/react/24/solid";
import getPostData from "@hey/helpers/getPostData";
import type { PostMention, RepostNotificationFragment } from "@hey/indexer";
import type { RepostNotificationFragment } from "@hey/indexer";
import Link from "next/link";
import plur from "plur";
import type { FC } from "react";
Expand Down Expand Up @@ -48,7 +48,7 @@ const RepostNotification: FC<RepostNotificationProps> = ({ notification }) => {
className="ld-text-gray-500 linkify mt-2 line-clamp-2"
href={`/posts/${notification.post.id}`}
>
<Markup mentions={notification.post.mentions as PostMention[]}>
<Markup mentions={notification.post.mentions}>
{filteredContent}
</Markup>
</Link>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Post/RelevantPeople.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import SingleAccountShimmer from "@components/Shared/Shimmer/SingleAccountShimme
import SingleAccount from "@components/Shared/SingleAccount";
import {
type AccountFragment,
type PostMention,
type PostMentionFragment,
useAccountsBulkQuery
} from "@hey/indexer";
import { Card, ErrorMessage, Modal } from "@hey/ui";
Expand All @@ -12,7 +12,7 @@ import { useAccountStore } from "src/store/persisted/useAccountStore";
import MoreRelevantPeople from "./MoreRelevantPeople";

interface RelevantPeopleProps {
mentions: PostMention[];
mentions: PostMentionFragment[];
}

const RelevantPeople: FC<RelevantPeopleProps> = ({ mentions }) => {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Shared/Markup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Regex } from "@hey/data/regex";
import trimify from "@hey/helpers/trimify";
import type { PostMention } from "@hey/indexer";
import type { PostMentionFragment } from "@hey/indexer";
import { type FC, memo } from "react";
import ReactMarkdown from "react-markdown";
import remarkBreaks from "remark-breaks";
Expand All @@ -21,7 +21,7 @@ const plugins = [
interface MarkupProps {
children: string;
className?: string;
mentions?: PostMention[];
mentions?: PostMentionFragment[];
}

const Markup: FC<MarkupProps> = ({
Expand Down
6 changes: 3 additions & 3 deletions packages/helpers/getMentions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Regex } from "@hey/data/regex";
import type { AccountMention, PostMention } from "@hey/indexer";
import type { AccountMentionFragment, PostMentionFragment } from "@hey/indexer";

const getMentions = (text: string): [] | PostMention[] => {
const getMentions = (text: string): [] | PostMentionFragment[] => {
if (!text) {
return [];
}
Expand All @@ -18,7 +18,7 @@ const getMentions = (text: string): [] | PostMention[] => {
from: handleWithoutNameSpace.toLowerCase(),
to: handleWithoutNameSpace.toLowerCase()
}
} as AccountMention;
} as AccountMentionFragment;
});

return processedMentions || [];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fragment GroupMention on GroupMention {
group
replace {
from
to
}
}
2 changes: 1 addition & 1 deletion packages/indexer/documents/fragments/post/PostBase.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fragment PostBase on Post {
...PostMetadata
}
mentions {
...AccountMention
...PostMention
}
timestamp
}
8 changes: 8 additions & 0 deletions packages/indexer/documents/fragments/post/PostMention.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fragment PostMention on PostMention {
... on AccountMention {
...AccountMention
}
... on GroupMention {
...GroupMention
}
}
57 changes: 38 additions & 19 deletions packages/indexer/generated.ts

Large diffs are not rendered by default.

0 comments on commit 2c45f64

Please sign in to comment.