Skip to content

Commit

Permalink
fix: caching maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
joelhooks committed Nov 27, 2024
1 parent c03b991 commit b439eac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
18 changes: 10 additions & 8 deletions src/components/pages/lessons/lesson/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -768,14 +768,16 @@ const Lesson: React.FC<React.PropsWithChildren<LessonProps>> = ({
</div>
</div>
</div>
<div className="flex flex-col items-center mt-4 text-sm opacity-80 md:items-start">
{created_at && (
<PublishedAt date={friendlyTime(new Date(created_at))} />
)}
{updated_at && (
<UpdatedAt date={friendlyTime(new Date(updated_at))} />
)}
</div>
{mounted && (
<div className="flex flex-col items-center mt-4 text-sm opacity-80 md:items-start">
{created_at && (
<PublishedAt date={friendlyTime(new Date(created_at))} />
)}
{updated_at && (
<UpdatedAt date={friendlyTime(new Date(updated_at))} />
)}
</div>
)}
{description && (
<Markdown className="font-medium prose prose-lg dark:prose-dark dark:prose-a:text-blue-300 prose-a:text-blue-500 max-w-none text-gray-1000 dark:text-white">
{description}
Expand Down
8 changes: 2 additions & 6 deletions src/lib/lessons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ const lessonQuery = groq`
'slug': slug.current,
description,
...resources[@->["_type"] == "videoResource"][0]->{
"dash_url": mediaUrls.dashUrl,
"media_url": mediaUrls.hlsUrl,
"transcript": transcript.text,
duration,
},
Expand Down Expand Up @@ -117,8 +115,9 @@ export async function loadLessonMetadataFromGraphQL(
export async function loadLesson(
slug: string,
token?: string,
useAuth?: boolean,
): Promise<LessonResource> {
token = token || getAccessTokenFromCookie()
token = useAuth ? token || getAccessTokenFromCookie() : undefined

/******************************************
* Primary Lesson Metadata GraphQL Request
Expand Down Expand Up @@ -224,7 +223,6 @@ const loadLessonGraphQLQuery = /* GraphQL */ `
hls_url
dash_url
http_url
media_url
lesson_view_url
thumb_url
icon_url
Expand Down Expand Up @@ -258,7 +256,6 @@ const loadLessonGraphQLQuery = /* GraphQL */ `
completed
duration
thumb_url
media_url
}
}
... on Course {
Expand All @@ -276,7 +273,6 @@ const loadLessonGraphQLQuery = /* GraphQL */ `
completed
duration
thumb_url
media_url
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/lessons/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const getServerSideProps: GetServerSideProps = async function ({

try {
const initialLesson: LessonResource | undefined =
params && (await loadLesson(params.slug as string))
params && (await loadLesson(params.slug as string, undefined, false))

if (initialLesson && initialLesson?.slug !== params?.slug) {
return {
Expand Down

0 comments on commit b439eac

Please sign in to comment.