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

Local storage of comment and submission drafts #1

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

Conversation

emekaorji
Copy link

@emekaorji emekaorji commented Jan 9, 2024

This PR adds the "Local storage of comment and submission drafts" suggested in the README.

Behaviour

  • Store unsubmitted comments for any post in local storage
  • If the user leaves and navigates back to that post to write a comment, they should find their previous unsubmitted comment still there
  • Once the user submits, clear the comment

Scope

Test

  • Setup and run the project locally using the guide in the README
  • Navigate to a story in the browser; should look like this /item/[storyId]
  • Begin writing a comment, the user should see the 'Saved to draft.' text beside the submit button
  • Stop writing the comment and refresh the page. After refreshing, the previously written comment should still be in the text area
  • Submit the form, this should clear the text from the text area and also from the local storage

Screenshot

Screen Recording 2024-01-09 at 01 14 57

Copy link

vercel bot commented Jan 9, 2024

@emekaorji is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@emapeire
Copy link

Great approach!

@rauchg
Copy link
Owner

rauchg commented Jan 13, 2024

Awesome work! I'm trying to avoid introducing too many dependencies. Would you mind inlining a minimal implementation of the local storage logic in lib/?

@emekaorji
Copy link
Author

Okay, sure! Doing that now.

@emekaorji
Copy link
Author

emekaorji commented Jan 14, 2024

Done! Added the hook to the lib dir
Also updated the PR description to include that change

lib/use-local-store.ts Outdated Show resolved Hide resolved
Copy link

@emapeire emapeire left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

3 participants