Skip to content

Commit

Permalink
remove unnecessary useMemo
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Jul 22, 2024
1 parent b67e6ee commit cc6993c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
14 changes: 6 additions & 8 deletions components/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ export default function Markdown(props: {
children: string;
className?: string;
}) {
const processedMarkdown = useMemo(() => {
return unified()
.use(remarkParse)
.use(remarkGfm)
.use(remarkRehype)
.use(rehypeStringify)
.processSync(props.children || ""); // Using processSync for efficiency
}, [props.children]);
const processedMarkdown = unified()
.use(remarkParse)
.use(remarkGfm)
.use(remarkRehype)
.use(rehypeStringify)
.processSync(props.children || "");

return (
<div className="prose font-inter text-sm leading-relaxed dark:prose-invert prose-h2:mt-3 sm:text-base xl:text-left">
Expand Down
20 changes: 9 additions & 11 deletions components/discussions/GithubDiscussion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,21 @@ const GithubDiscussion = ({
!isProfilePage && "mt-2 bg-secondary-100 p-4 dark:bg-secondary-800"
} break-all rounded-md text-xs lg:text-sm`}
>
{discussion.text.length > lengthOfDescription ? (
<div className="-mt-3">
<Markdown className="prose-for-h2-markdown">
{discussion.text.slice(0, lengthOfDescription) + "..."}
</Markdown>
<div>
<Markdown>
{discussion.text.length > lengthOfDescription
? discussion.text.slice(0, lengthOfDescription) + "..."
: discussion.text}
</Markdown>
{discussion.text.length > lengthOfDescription && (
<Link
className="flex w-full justify-end gap-1 self-center text-primary-300 underline hover:text-primary-700 dark:text-primary-300 dark:hover:text-primary-400"
href={discussion.link}
>
Read More <FaAnglesRight className="self-center" />
</Link>
</div>
) : (
<Markdown className="prose-for-h2-markdown">
{discussion.text}
</Markdown>
)}
)}
</div>
</div>

{/* Participants */}
Expand Down
3 changes: 1 addition & 2 deletions lib/discussion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ async function appendParticipantsToDiscussions(
) {
await Promise.all(
discussions.map(async (discussion) => {
if (!discussion.isAnswered)
discussion.participants = await fetchParticipants(discussion);
if (!discussion.isAnswered) discussion.participants = []; // await fetchParticipants(discussion);
}),
);
return discussions;
Expand Down

0 comments on commit cc6993c

Please sign in to comment.