From 59a45866fa755c3478834d30c315aa0c0a3768b5 Mon Sep 17 00:00:00 2001 From: Parvat Raj Singh <42418677+paahaad@users.noreply.github.com> Date: Sat, 5 Oct 2024 03:41:38 +0530 Subject: [PATCH] fix bookmark and view of bookmark (#1232) --- src/actions/bookmark/types.ts | 1 + src/components/CourseView.tsx | 4 ++-- src/components/bookmark/BookmarkList.tsx | 20 ++++++++++++++++++-- src/db/bookmark.ts | 6 ++++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/actions/bookmark/types.ts b/src/actions/bookmark/types.ts index be76ca3ac..06155c745 100644 --- a/src/actions/bookmark/types.ts +++ b/src/actions/bookmark/types.ts @@ -17,5 +17,6 @@ export type ReturnTypeDeleteBookmark = ActionState< export type TBookmarkWithContent = Bookmark & { content: Content & { parent: { id: number; courses: CourseContent[] } | null; + courses: CourseContent[]; }; }; diff --git a/src/components/CourseView.tsx b/src/components/CourseView.tsx index ccbaba319..45f5689f9 100644 --- a/src/components/CourseView.tsx +++ b/src/components/CourseView.tsx @@ -64,7 +64,7 @@ export const CourseView = ({ description: courseContent?.value?.description || '', markAsCompleted: courseContent?.value?.videoProgress?.markAsCompleted || false, - bookmark: courseContent?.value.bookmark ?? null, + bookmark: courseContent?.value.bookmark || null, }} /> ) : null} @@ -95,7 +95,7 @@ export const CourseView = ({ percentComplete: getFolderPercentCompleted(x?.children), videoFullDuration: x?.videoProgress?.videoFullDuration || 0, duration: x?.videoProgress?.duration || 0, - bookmark: null, + bookmark: x.bookmark || null, }))} courseId={parseInt(course.id, 10)} /> diff --git a/src/components/bookmark/BookmarkList.tsx b/src/components/bookmark/BookmarkList.tsx index f8d9490e7..0bbe4cec8 100644 --- a/src/components/bookmark/BookmarkList.tsx +++ b/src/components/bookmark/BookmarkList.tsx @@ -21,13 +21,29 @@ const BookmarkList = ({ {bookmarkData.map((bookmark) => { const { contentId, - content: { type, parent, title, hidden, thumbnail }, + content: { type, parent, title, hidden, thumbnail, courses }, } = bookmark; - if (type === 'video' && parent && !hidden) { + if ((type === 'video' || type === 'notion') && parent && !hidden) { const { id: folderId, courses } = parent; const courseId = courses[0].courseId; const videoUrl = `/courses/${courseId}/${folderId}/${contentId}`; + return ( + { + router.push(videoUrl); + }} + bookmark={bookmark} + contentId={contentId} + /> + ); + } else if (type === 'folder' && !parent) { + const videoUrl = `/courses/${courses[0].courseId}/${courses[0].contentId}`; + return (