From cc6993ce295cf7eecdfbfc0d423642e657339bda Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Mon, 22 Jul 2024 10:17:07 +0530 Subject: [PATCH] remove unnecessary `useMemo` --- components/Markdown.tsx | 14 ++++++-------- components/discussions/GithubDiscussion.tsx | 20 +++++++++----------- lib/discussion.ts | 3 +-- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/components/Markdown.tsx b/components/Markdown.tsx index 739affe2..2d474fec 100644 --- a/components/Markdown.tsx +++ b/components/Markdown.tsx @@ -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 (
diff --git a/components/discussions/GithubDiscussion.tsx b/components/discussions/GithubDiscussion.tsx index f1cb6f72..146c0336 100644 --- a/components/discussions/GithubDiscussion.tsx +++ b/components/discussions/GithubDiscussion.tsx @@ -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 ? ( -
- - {discussion.text.slice(0, lengthOfDescription) + "..."} - +
+ + {discussion.text.length > lengthOfDescription + ? discussion.text.slice(0, lengthOfDescription) + "..." + : discussion.text} + + {discussion.text.length > lengthOfDescription && ( Read More -
- ) : ( - - {discussion.text} - - )} + )} +
{/* Participants */} diff --git a/lib/discussion.ts b/lib/discussion.ts index c37fa99b..fc9f862b 100644 --- a/lib/discussion.ts +++ b/lib/discussion.ts @@ -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;