From e032401378cda9f704e2479d89e582f2cbcbad81 Mon Sep 17 00:00:00 2001 From: Terry Sahaidak Date: Tue, 15 Mar 2016 22:45:40 +0200 Subject: [PATCH] Fix crash on pop from loginByToken; duplicating faye events after logining --- app/modules/app.js | 2 +- app/modules/realtime.js | 2 +- app/modules/rooms.js | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/modules/app.js b/app/modules/app.js index ca05c54..4ebcfae 100644 --- a/app/modules/app.js +++ b/app/modules/app.js @@ -19,7 +19,6 @@ export const CHANGE_APP_STATE = 'app/CHANGE_APP_STATE' export function init() { return async (dispatch, getState) => { dispatch(setupAppStatusListener()) - dispatch(setupFayeEvents()) try { // checking internet connection const netStatus = await NetInfo.fetch() @@ -34,6 +33,7 @@ export function init() { return } + dispatch(setupFayeEvents()) dispatch({ type: INITIALIZED, token }) // getting base current user's information diff --git a/app/modules/realtime.js b/app/modules/realtime.js index 17a07c7..e6d99f5 100644 --- a/app/modules/realtime.js +++ b/app/modules/realtime.js @@ -90,7 +90,7 @@ export function setupFayeEvents() { function parseEvent(event) { return (dispatch, getState) => { const message = JSON.parse(event.json) - console.log('MESSAGE!!!', message) + const {id} = getState().viewer.user const {activeRoom} = getState().rooms const roomsChannel = `/api/v1/user/${id}/rooms` diff --git a/app/modules/rooms.js b/app/modules/rooms.js index a230642..3eefb1b 100644 --- a/app/modules/rooms.js +++ b/app/modules/rooms.js @@ -94,6 +94,11 @@ export function getSuggestedRooms() { export function selectRoom(roomId) { return (dispatch, getState) => { const {activeRoom} = getState().rooms + + if (roomId === '') { + return + } + dispatch({type: SELECT_ROOM, payload: roomId}) if (!!activeRoom) { dispatch(unsubscribeToChatMessages(activeRoom))