Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Post completion overlay #1505

Merged
merged 9 commits into from
Jan 31, 2025
Merged

feat: Post completion overlay #1505

merged 9 commits into from
Jan 31, 2025

Conversation

zacjones93
Copy link
Contributor

This adds completion overlay to posts so we can CTA Johns workshop on cursor lessons.

Cursor CTA

desktop

Mobile is a little crowded but it looks ok:
mobile

Default

default desktop

gif

Not sure why we index on the front end but this was removing tags from indexed posts and generally out of sync with builder
- add CTA to Cursor workshop for posts tagged with cursor
- pull tags from course builder
Copy link

vercel bot commented Jan 31, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
egghead-io-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 31, 2025 11:31pm

Comment on lines -286 to -316
let client = new Typesense.Client({
nodes: [
{
host: process.env.NEXT_PUBLIC_TYPESENSE_HOST!,
port: 443,
protocol: 'https',
},
],
apiKey: process.env.TYPESENSE_WRITE_API_KEY!,
connectionTimeoutSeconds: 2,
})

if (
post.fields.state === 'published' &&
post.fields.visibility === 'public'
) {
await client
.collections(process.env.TYPESENSE_COLLECTION_NAME!)
.documents()
.upsert({
...resource,
published_at_timestamp: post.updatedAt.getTime(),
})
.catch((err) => {})
} else {
await client
.collections(process.env.TYPESENSE_COLLECTION_NAME!)
.documents()
.delete(resource.id)
.catch((err) => {})
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Typesense indexing is out of sync with course builder and seems redundant. Currently it strip the indexed typesense objects of tags because when this was implemented we weren't indexing tags in posts..

Comment on lines +390 to +402
<MuxPlayerProvider>
<VideoPlayerOverlayProvider>
<div className="relative h-full w-full">
<VideoPlayerOverlay resource={post} />
<PostPlayer
playbackId={videoResource.fields.muxPlaybackId}
eggheadLessonId={post.fields.eggheadLessonId}
post={post}
postTags={tags}
/>
</div>
</VideoPlayerOverlayProvider>
</MuxPlayerProvider>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding mux and overlay provider which gives controls for overlay to be triggered and access mux player to rewatch lesson

Comment on lines +586 to +601
ref={playerRef}
onLoadedData={() => {
dispatchVideoPlayerOverlay({type: 'HIDDEN'})
setMuxPlayerRef(playerRef)
}}
onEnded={() => {
if (eggheadLessonId) {
if (postTags.some((tag) => tag.name === 'cursor')) {
dispatchVideoPlayerOverlay({
type: 'COMPLETED',
playerRef,
cta: 'cursor_workshop',
})
} else {
dispatchVideoPlayerOverlay({type: 'COMPLETED', playerRef})
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on load we want to make sure overlay is hidden

on ended we want to trigger completion overlay. When lessons are tagged with cursor we'll send cursor_workshop CTA to display custom overlay

case 'COMPLETED':
const {playerRef, cta} = overlayState.action as CompletedAction

if (cta === 'cursor_workshop') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if cta is cursor_workshop display the custom overlay, otherwise display default

Comment on lines +57 to +73
<div className="flex flex-col items-center justify-center gap-2 p-4">
<h2 className="text-lg sm:text-2xl font-bold mb-4 text-center">
{resource.fields.title}
</h2>
<Button
variant="outline"
onClick={() => {
if (playerRef.current) {
playerRef.current.play()
}
dispatch({type: 'HIDDEN'})
}}
className="border border-blue-600 hover:bg-blue-600"
>
<RefreshCw className="mr-2 h-4 w-4" />
Watch again
</Button>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default overlay is simple right now with a watch again button. @vojtaholik we could put vector search results here if we implemented that

@zacjones93 zacjones93 changed the title Zac/cursor workshop cta feat: Post completion overlay Jan 31, 2025
@zacjones93 zacjones93 merged commit f0d93bc into main Jan 31, 2025
6 checks passed
@kodiakhq kodiakhq bot deleted the zac/cursor-workshop-cta branch January 31, 2025 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants