mirror of
https://github.com/outline/outline.git
synced 2026-12-02 01:34:47 +03:00
fix: timeout leak in useIdle (#12908)
This commit is contained in:
1 parent
a60373118c
commit
3cc39e61c0
1 file changed
+9
@@ -53,7 +53,16 @@ export default function useIdle(
|
||||
events.forEach((eventName) =>
|
||||
window.addEventListener(eventName, handleUserActivityEvent)
|
||||
);
|
||||
|
||||
// Start the countdown immediately, otherwise the user is never considered
|
||||
// idle unless activity occurs after mount.
|
||||
onActivity();
|
||||
|
||||
return () => {
|
||||
handleUserActivityEvent.cancel();
|
||||
if (timeout.current) {
|
||||
clearTimeout(timeout.current);
|
||||
}
|
||||
events.forEach((eventName) =>
|
||||
window.removeEventListener(eventName, handleUserActivityEvent)
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user