2022-02-28 18:00:47 +00:00
|
|
|
import { Action } from 'redux';
|
|
|
|
|
2017-08-17 01:06:31 +00:00
|
|
|
import { METEOR } from '../actions/actionsTypes';
|
|
|
|
|
2022-02-28 18:00:47 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2022-02-28 18:00:47 +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,
|
2019-02-12 16:14:11 +00:00
|
|
|
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-12-20 19:20:06 +00:00
|
|
|
};
|
2017-08-17 16:55:47 +00:00
|
|
|
case METEOR.DISCONNECT:
|
|
|
|
return initialState;
|
2017-08-17 01:06:31 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|