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

45 lines
825 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: '',
disconnected_by_user: false,
2017-08-17 01:06:31 +00:00
failure: false
};
export default function connect(state = initialState, action) {
switch (action.type) {
case METEOR.REQUEST:
2017-11-13 12:58:35 +00:00
return {
...state,
connecting: true,
disconnected_by_user: false
2017-08-17 01:06:31 +00:00
};
case METEOR.SUCCESS:
2017-11-13 12:58:35 +00:00
return {
...state,
2017-08-17 01:06:31 +00:00
connecting: false,
connected: true,
failure: false
};
case METEOR.FAILURE:
2017-11-13 12:58:35 +00:00
return {
...state,
2017-08-17 01:06:31 +00:00
connecting: false,
connected: false,
failure: true,
errorMessage: action.err
};
case METEOR.DISCONNECT_BY_USER:
return {
...state,
disconnected_by_user: true
};
2017-08-17 16:55:47 +00:00
case METEOR.DISCONNECT:
return initialState;
2017-08-17 01:06:31 +00:00
default:
return state;
}
}