mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 11:47:23 +03:00
Live location sharing: fix code smells - return useEffect unsub, dont map (#8535)
Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
parent
aa8e3dbfb4
commit
7e15bef062
1 changed files with 2 additions and 2 deletions
|
@ -68,13 +68,13 @@ const useLivenessMonitor = (liveBeaconIds: BeaconIdentifier[], beacons: Map<Beac
|
|||
// refresh beacon monitors when the tab becomes active again
|
||||
const onPageVisibilityChanged = () => {
|
||||
if (document.visibilityState === 'visible') {
|
||||
liveBeaconIds.map(identifier => beacons.get(identifier)?.monitorLiveness());
|
||||
liveBeaconIds.forEach(identifier => beacons.get(identifier)?.monitorLiveness());
|
||||
}
|
||||
};
|
||||
if (liveBeaconIds.length) {
|
||||
document.addEventListener("visibilitychange", onPageVisibilityChanged);
|
||||
}
|
||||
() => {
|
||||
return () => {
|
||||
document.removeEventListener("visibilitychange", onPageVisibilityChanged);
|
||||
};
|
||||
}, [liveBeaconIds, beacons]);
|
||||
|
|
Loading…
Reference in a new issue