Add back browser button support for callouts
What does this MR do and why?
- when a callout is dismissed it is marked in the database so that it does not show again. however if a user navigates back via the browser, the cached page does not have the updated dismissed status and the user will see the callout again. this MR:
- stores a timestamp for the callout in local storage
- cleans up local storage callout items if the timestamp is older than 2 hours
- cleanup only occurs when the class is rendered (on another page that uses this dismissible callout)
- see #412475
References
Screenshots or screen recordings
No visual changes
How to set up and validate locally
- Find a page that uses this persistent_user_callout class (example: http://127.0.0.1:3000/dashboard/merge_requests/search)
- Callout:
Your merge requests have a new homepage!
- Callout:
- Open up the console -> Application -> Local Storage
- Dismiss the callout
- Observe the callout key get added to local storage
- Observe new callout registry has the key in an array
- Observe the callout get added to the database (table: user_callouts)
- Navigate to another page
- Click the browser "back" button
- The callout may flash but should NOT reappear
- To check that local storage clean up occurs. you can alter the local storage timestamp to be greater than 2 hours prior
- Follow steps 4 - 5
- You should see the callout key is removed and the registry key is an empty array.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #412475
Edited by Kiesha Herman