Rocket.Chat.ReactNative/app/reducers/connect.js

35 lines
653 B
JavaScript
Raw Normal View History

2017-08-17 01:06:31 +00:00
import { METEOR } from '../actions/actionsTypes';
const initialState = {
connecting: false,
connected: false,
errorMessage: '',
failure: false
};
export default function connect(state = initialState, action) {
switch (action.type) {
case METEOR.REQUEST:
return { ...state,
connecting: true
};
case METEOR.SUCCESS:
return { ...state,
connecting: false,
connected: true,
failure: false
};
case METEOR.FAILURE:
return { ...state,
connecting: false,
connected: false,
failure: true,
errorMessage: action.err
};
2017-08-17 16:55:47 +00:00
case METEOR.DISCONNECT:
return initialState;
2017-08-17 01:06:31 +00:00
default:
return state;
}
}