mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-07-27 03:42:14 +00:00
Merge pull request #1335 from dexteresc/fix-missed-focus-event
Some checks failed
Build / build (push) Has been cancelled
Some checks failed
Build / build (push) Has been cancelled
fix: missed window focus event leaves model state subscriptions unattached
This commit is contained in:
commit
f543ff4d29
1 changed files with 3 additions and 0 deletions
|
|
@ -15,6 +15,9 @@ const useRouteFocused = () => {
|
|||
window.addEventListener('focus', handleFocus);
|
||||
window.addEventListener('blur', handleBlur);
|
||||
|
||||
// catch focus changes that happened before the listeners were attached
|
||||
setIsFocused(document.hasFocus());
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('focus', handleFocus);
|
||||
window.removeEventListener('blur', handleBlur);
|
||||
|
|
|
|||
Loading…
Reference in a new issue