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:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user