-
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
✨ Clear event list on page reload for SDK extension #1825
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1825 +/- ##
==========================================
- Coverage 93.11% 93.03% -0.08%
==========================================
Files 131 131
Lines 5081 5081
Branches 1138 1138
==========================================
- Hits 4731 4727 -4
- Misses 350 354 +4
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
if (!preserveEvents) { | ||
const clearCurrentEvents = (details: chrome.webNavigation.WebNavigationTransitionCallbackDetails) => { | ||
if (details.transitionType === 'reload') setEvents([]) | ||
} | ||
chrome.webNavigation.onCommitted.addListener(clearCurrentEvents) | ||
return () => { | ||
removeListener() | ||
chrome.webNavigation.onCommitted.removeListener(clearCurrentEvents) | ||
} | ||
} |
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.
Because of this early return, the removeListener
won't always be called. What about using two useEffect
like I suggested here?
Motivation
Clear events when we refresh page
Testing
I have gone over the contributing documentation.