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

Save the code and add checkpoint so the users can start from where they left off #102

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

pavanydg
Copy link
Contributor

What kind of change does this PR introduce?
Saves the code of each lesson if user has written any code in it.
Also adds a checkpoint from where users can resume their learning when open the website again.

Issue Number:

Screenshots/videos:

Screencast.from.10-17-2024.11.25.16.PM.webm

If relevant, did you update the documentation?

Summary

Does this PR introduce a breaking change?

import { getCheckPoint } from '@/lib/progressSaving'


export default function CheckpointRedirect() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question as in the previous PR: is there any reason to implement the redirect in a component, instead of a plan function?
I can't see much reason for using useEffect() here - @JeelRajodiya can you please advise?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know if there is any other way to redirect without useEffect in this case.

I think @pavanydg has separated the code in a component because it requires the client side hook useEffect(), while our home page is a server side component. (When to use Server and Client Components?)

@@ -85,7 +98,9 @@ export default function CodeEditor({
theme={colorMode === "light" ? "light" : "my-theme"}
value={codeString}
height={"100%"}
onChange={(codeString) => setCodeString(codeString ? codeString : "")}
onChange={(codeString) =>
setCodeString(codeString ? codeString : "")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please use either || or ?? operator here?

@@ -83,6 +85,7 @@ export default function NavBarMenu() {
duration: 3000,
isClosable: true,
});
window.location.reload();
Copy link
Member

Choose a reason for hiding this comment

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

Can we please avoid reloading the whole window?

Copy link
Member

Choose a reason for hiding this comment

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

you can consider using global state management solution such as zustand (we are already using it in our repo here)

import { getCheckPoint } from '@/lib/progressSaving'


export default function CheckpointRedirect() {
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if there is any other way to redirect without useEffect in this case.

I think @pavanydg has separated the code in a component because it requires the client side hook useEffect(), while our home page is a server side component. (When to use Server and Client Components?)

@JeelRajodiya
Copy link
Member

JeelRajodiya commented Oct 30, 2024

@pavanydg Great work! the feature is working as expected, we just need some refactoring in the code. Please see my comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Save the code and a checkpoint so the users can start from where they left off
3 participants