Skip to content

Commit

Permalink
Fix crash on pop from loginByToken; duplicating faye events after log…
Browse files Browse the repository at this point in the history
…ining
  • Loading branch information
terrysahaidak committed Mar 15, 2016
1 parent 3a460ab commit e032401
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/modules/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -34,6 +33,7 @@ export function init() {
return
}

dispatch(setupFayeEvents())
dispatch({ type: INITIALIZED, token })

// getting base current user's information
Expand Down
2 changes: 1 addition & 1 deletion app/modules/realtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
5 changes: 5 additions & 0 deletions app/modules/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit e032401

Please sign in to comment.