-
Notifications
You must be signed in to change notification settings - Fork 102
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
[RHCLOUD-30109] Batch updates for last-visited-pages #1959
Conversation
146892f
to
1a9584e
Compare
console.error('Unable to update last visited pages!', error); | ||
} | ||
// Save state from localStorage on an interval | ||
setInterval(async () => { |
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.
You have to clear the interval in the useEffect cleanup phase. Currently this can cause memory leaks.
} | ||
// Save state from localStorage on an interval | ||
setInterval(async () => { | ||
await updateMostRecentPages(); |
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.
No reason to await this call. We are not working with the return value.
return () => { | ||
titleObserver?.disconnect(); | ||
postDataDebounced?.cancel(); | ||
document.removeEventListener('visibilitychange', handleVisibilityChange); |
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.
We should also clear the inactiveTimeout.current
here if it exists.
const lastVisited = localStorage.getItem(LAST_VISITED_FLAG); | ||
if (lastVisited) { | ||
const lastVisitedLocal = localStorage.getItem(LAST_VISITED_FLAG); | ||
const getInitialPages = async () => { |
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 function should be defined out of the effect.
c365daa
to
4907546
Compare
packages/chrome/package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "@redhat-cloud-services/chrome", | |||
"version": "1.0.7", | |||
"version": "1.0.8", |
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 is automated no need to bump the version manually.
4907546
to
4e192cc
Compare
:soon::shipit::octocat: |
🌱 🌸 🌷 🌻 🌟 New version of package has been released 🌟 🌻 🌷 🌸 🌱 The release is available on: :package:@redhat-cloud-services/chrome/v/1.0.8📦 :boom:This feature is brought to you by probot🚀 |
Migrates the
useLastVisitedPages
hook to only push batch updates to the APIhidden
for 20 seconds, the user's last 10 pages from localStorage will be saved in the DB