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

35 lines
625 B
TypeScript
Raw Normal View History

import { Action } from 'redux';
2017-08-17 01:06:31 +00:00
import { METEOR } from '../actions/actionsTypes';
export interface IConnect {
connecting: boolean;
connected: boolean;
}
export const initialState: IConnect = {
2017-08-17 01:06:31 +00:00
connecting: false,
2018-12-05 20:52:08 +00:00
connected: false
2017-08-17 01:06:31 +00:00
};
export default function connect(state = initialState, action: Action): IConnect {
2017-08-17 01:06:31 +00:00
switch (action.type) {
case METEOR.REQUEST:
2017-11-13 12:58:35 +00:00
return {
...state,
connecting: true,
connected: 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,
2018-12-05 20:52:08 +00:00
connected: 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;
}
}