Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return async (dispatch: Function) => {
const { user } = await storage.get('user');
if (!user) return;
const { username } = user;
Intercom.registerIdentifiedUser({ userId: username });
Intercom.updateUser({ user_id: username, name: username });
intercomNotificationsListener = ({ count }) => dispatch({
type: UPDATE_INTERCOM_NOTIFICATIONS_COUNT,
payload: count,
});
Intercom.getUnreadConversationCount()
.then(count => ({ count }))
.then(intercomNotificationsListener)
.catch(() => { });
Intercom.addEventListener(Intercom.Notifications.UNREAD_COUNT, intercomNotificationsListener);
};
};