From 542555d3bb8deb6786a9702c8cbefdec4a62e6a9 Mon Sep 17 00:00:00 2001 From: enahum Date: Wed, 1 Mar 2017 12:36:23 -0300 Subject: [PATCH] PLT-5678 Ensure all connections are closed on logout (#314) --- service/actions/users.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/service/actions/users.js b/service/actions/users.js index c2667ba85..5dd0c728b 100644 --- a/service/actions/users.js +++ b/service/actions/users.js @@ -377,7 +377,17 @@ export function startPeriodicStatusUpdates() { statusIntervalId = setInterval( () => { const {statuses} = getState().entities.users; - getStatusesByIds(Object.keys(statuses))(dispatch, getState); + + if (!statuses) { + return; + } + + const userIds = Object.keys(statuses); + if (!userIds.length) { + return; + } + + getStatusesByIds(userIds)(dispatch, getState); }, Constants.STATUS_INTERVAL ); @@ -386,7 +396,9 @@ export function startPeriodicStatusUpdates() { export function stopPeriodicStatusUpdates() { return async () => { - clearInterval(statusIntervalId); + if (statusIntervalId) { + clearInterval(statusIntervalId); + } }; }