37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import * as types from "./actionTypes";
|
|
import api from "./api";
|
|
import { sendHttpRequest } from "../../redux/actions/httpActions";
|
|
|
|
export function loadServerSessions() {
|
|
return async function(dispatch) {
|
|
try {
|
|
dispatch({ type: types.LOAD_SERVER_SESSIONS_STARTED });
|
|
const data = await dispatch(sendHttpRequest(api.getServerSessions()));
|
|
dispatch({ type: types.LOAD_SERVER_SESSIONS_SUCCESS, payload: data });
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
};
|
|
}
|
|
|
|
export function loadSessionForwards(sessionId) {
|
|
return async function(dispatch, getState) {
|
|
try {
|
|
const forwards = getState().forwards[sessionId];
|
|
if (forwards && (forwards.loading || forwards.loaded)) return;
|
|
|
|
dispatch({ type: types.LOAD_SESSION_FORWARDS_STARTED, id: sessionId });
|
|
const data = await dispatch(
|
|
sendHttpRequest(api.getSessionForwards(sessionId))
|
|
);
|
|
dispatch({
|
|
type: types.LOAD_SESSION_FORWARDS_SUCCESS,
|
|
payload: data,
|
|
id: sessionId
|
|
});
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
};
|
|
}
|