-
Notifications
You must be signed in to change notification settings - Fork 140
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
Refactor useBackupReminder hook #528
base: master
Are you sure you want to change the base?
Refactor useBackupReminder hook #528
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
fb67e90
to
22dbfbc
Compare
|
I believe it is, the only people who access both local dev and live are developers. This is really a DX improvement without any downside for users. |
> | ||
Remind me in {reminderInDays} days | ||
</Button> | ||
<div className="flex flex-col gap-2"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔ This could/should be a form
for better semantics/accessibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be an interesting "future" thing to see if this could be converted to the new(ish) popover stuff
suppressReminder(reminderInDays); | ||
}} | ||
> | ||
Remind me in {reminderInDays} days |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe
Remind me in {reminderInDays} days | |
Remind me in {reminderInDays} day{reminderInDays > 1 ? 's' : ''} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, I added this into the refactor I did based on this feedback. Thanks
); | ||
setReminderState({ | ||
suppressed: true, | ||
lastShown: new Date().toISOString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you mean to do this?
lastShown: new Date().toISOString(), | |
lastShown: new Date().toISOString(), | |
expires: expiryDate.toISOString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this, I'm not sure why I thought I needed this extra logic, I did a small refactor using expires instead of supressed and lastShown props.
6d00b60
to
a7a448c
Compare
Description
This PR refactors the useBackupReminder hook to use localStorage for persistence instead of relying on cookies (js-cookie). This change improves the reliability of storing reminder state, and will allow a single dismiss action to be read across domains (local dev vs live)
Using cookies limited persistence to the specific domain and environment where the reminder was dismissed. By moving to localStorage, the dismissed state can now persist across local development and live environments (when the same storage is accessible), improving the developer experience and preventing repeated backup reminders between local development and live.
Changes Made
Displays the backup reminder toast based on the last shown date and suppression state.
Allows users to dismiss the reminder forever (10 years), take action, dismiss for one week.
Testing Done
Tests have been added for useToast and useLocalStorage hooks, including the Toast component
Screenshots (if applicable)
(the size of the dialog has remained the same fyi)

before:
after:

Checklist
Additional Notes