Merge pull request #19 from jfurrow/feature/cleanup-actions

Cleanup actions
This commit is contained in:
John Furrow
2016-06-05 10:37:19 -07:00
3 changed files with 55 additions and 47 deletions
@@ -4,50 +4,6 @@ import AppDispatcher from '../dispatcher/AppDispatcher';
import ActionTypes from '../constants/ActionTypes';
const ClientActions = {
fetchTransferData: () => {
return axios.get('/stats')
.then((json = {}) => {
return json.data;
})
.then((transferData) => {
AppDispatcher.dispatchServerAction({
type: ActionTypes.CLIENT_FETCH_TRANSFER_DATA_SUCCESS,
data: {
transferData
}
});
})
.catch((error) => {
AppDispatcher.dispatchServerAction({
type: ActionTypes.CLIENT_FETCH_TRANSFER_DATA_ERROR,
data: {
error
}
});
});
},
fetchTransferHistory: (opts) => {
return axios.get('/history', {
params: opts
})
.then((json = {}) => {
return json.data;
})
.then((data) => {
AppDispatcher.dispatchServerAction({
type: ActionTypes.CLIENT_FETCH_TRANSFER_HISTORY_SUCCESS,
data
});
})
.catch((error) => {
AppDispatcher.dispatchServerAction({
type: ActionTypes.CLIENT_FETCH_TRANSFER_HISTORY_ERROR,
error
});
});
},
setThrottle: (direction, throttle) => {
return axios.put('/client/settings/speed-limits', {
direction,
@@ -0,0 +1,52 @@
import axios from 'axios';
import AppDispatcher from '../dispatcher/AppDispatcher';
import ActionTypes from '../constants/ActionTypes';
const FloodActions = {
fetchTransferData: () => {
return axios.get('/stats')
.then((json = {}) => {
return json.data;
})
.then((transferData) => {
AppDispatcher.dispatchServerAction({
type: ActionTypes.CLIENT_FETCH_TRANSFER_DATA_SUCCESS,
data: {
transferData
}
});
})
.catch((error) => {
AppDispatcher.dispatchServerAction({
type: ActionTypes.CLIENT_FETCH_TRANSFER_DATA_ERROR,
data: {
error
}
});
});
},
fetchTransferHistory: (opts) => {
return axios.get('/history', {
params: opts
})
.then((json = {}) => {
return json.data;
})
.then((data) => {
AppDispatcher.dispatchServerAction({
type: ActionTypes.CLIENT_FETCH_TRANSFER_HISTORY_SUCCESS,
data
});
})
.catch((error) => {
AppDispatcher.dispatchServerAction({
type: ActionTypes.CLIENT_FETCH_TRANSFER_HISTORY_ERROR,
error
});
});
}
};
export default FloodActions;
@@ -1,9 +1,9 @@
import ActionTypes from '../constants/ActionTypes';
import AppDispatcher from '../dispatcher/AppDispatcher';
import BaseStore from './BaseStore';
import ClientActions from '../actions/ClientActions';
import config from '../../../../config';
import EventTypes from '../constants/EventTypes';
import FloodActions from '../actions/FloodActions';
class TransferDataStoreClass extends BaseStore {
constructor() {
@@ -18,14 +18,14 @@ class TransferDataStoreClass extends BaseStore {
fetchTransferData() {
if (!this.isRequestPending('fetch-transfer-history')) {
this.beginRequest('fetch-transfer-history');
ClientActions.fetchTransferHistory({
FloodActions.fetchTransferHistory({
snapshot: 'fiveMin'
});
}
if (!this.isRequestPending('fetch-transfer-data')) {
this.beginRequest('fetch-transfer-data');
ClientActions.fetchTransferData();
FloodActions.fetchTransferData();
}
if (this.pollTransferDataID === null) {