2017-08-21 03:00:41 +00:00
|
|
|
import { put, takeEvery, call } from 'redux-saga/effects';
|
|
|
|
import { AsyncStorage } from 'react-native';
|
2017-08-18 21:30:16 +00:00
|
|
|
import { SERVER } from '../actions/actionsTypes';
|
|
|
|
import { connectRequest, disconnect } from '../actions/connect';
|
|
|
|
import { changedServer } from '../actions/server';
|
|
|
|
|
2017-08-21 03:00:41 +00:00
|
|
|
const selectServer = function* selectServer({ server }) {
|
2017-08-21 00:11:46 +00:00
|
|
|
yield put(disconnect());
|
|
|
|
yield put(changedServer(server));
|
2017-08-21 03:00:41 +00:00
|
|
|
yield console.log('SERVER->', server);
|
|
|
|
yield call([AsyncStorage, 'setItem'], 'currentServer', server);
|
2017-08-21 00:11:46 +00:00
|
|
|
yield put(connectRequest(server));
|
2017-08-18 21:30:16 +00:00
|
|
|
};
|
|
|
|
const root = function* root() {
|
|
|
|
yield takeEvery(SERVER.SELECT, selectServer);
|
|
|
|
};
|
|
|
|
export default root;
|