Skip to content

Commit

Permalink
Merge pull request #602 from mvp5464/replyError
Browse files Browse the repository at this point in the history
Fix: Error while replying to comments + clicking on timestamp + going back from reply
  • Loading branch information
siinghd authored Jun 15, 2024
2 parents a198c79 + a8adeac commit 7bab81c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/CourseView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const CourseView = ({
<Comments
content={{
id: courseContent[0]?.id || 0,
courseId: courseContent[0]?.parentId || 0,
courseId: parseInt(course.id, 10) || 0,
commentCount: courseContent[0]?.commentsCount || 0,
possiblePath,
}}
Expand Down
6 changes: 4 additions & 2 deletions src/components/comment/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const Comments = async ({
<Link
className="p-1"
href={getUpdatedUrl(
`/courses/${content.possiblePath}`,
`/courses/${content.courseId}/${content.possiblePath}`,
modifiedSearchParams,
{},
)}
Expand All @@ -86,6 +86,7 @@ const Comments = async ({
possiblePath={content.possiblePath}
searchParams={searchParams}
comment={data.parentComment.content}
contentId={content.courseId}
/>
</h1>
)}
Expand Down Expand Up @@ -285,6 +286,7 @@ const Comments = async ({
possiblePath={content.possiblePath}
searchParams={searchParams}
comment={c.content}
contentId={content.courseId}
/>
</div>

Expand All @@ -300,7 +302,7 @@ const Comments = async ({
{!data.parentComment && (
<Link
href={getUpdatedUrl(
`/courses/${content.possiblePath}`,
`/courses/${content.courseId}/${content.possiblePath}`,
searchParams,
{
parentId: c.id,
Expand Down
12 changes: 9 additions & 3 deletions src/components/comment/TimeCodeComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ type TimeCodeCommentProps = {
comment: string;
possiblePath: string;
searchParams: QueryParams;
contentId: number;
};

const TimeCodeComment: React.FC<TimeCodeCommentProps> = ({
comment,
possiblePath,
searchParams,
contentId,
}) => {
const timeCodeRegex = /(?:(\d{1,2}):)?(\d{1,2}):(\d{1,2})/g;
const urlRegex = /((https)?:\/\/[^\s]+)/g;
Expand Down Expand Up @@ -44,9 +46,13 @@ const TimeCodeComment: React.FC<TimeCodeCommentProps> = ({
<Link
key={`timecode-${match.index}`}
className="text-blue-500 hover:underline"
href={getUpdatedUrl(`/courses/${possiblePath}`, searchParams, {
timestamp: timeInSeconds,
})}
href={getUpdatedUrl(
`/courses/${contentId}/${possiblePath}`,
searchParams,
{
timestamp: timeInSeconds,
},
)}
>
{match[0]}
</Link>,
Expand Down

0 comments on commit 7bab81c

Please sign in to comment.