2020-04-01 12:38:08 -07:00
|
|
|
import api from '../api';
|
|
|
|
|
2020-06-03 12:24:53 -07:00
|
|
|
export const SOAPBOX_CONFIG_REQUEST_SUCCESS = 'SOAPBOX_CONFIG_REQUEST_SUCCESS';
|
|
|
|
export const SOAPBOX_CONFIG_REQUEST_FAIL = 'SOAPBOX_CONFIG_REQUEST_FAIL';
|
2020-04-01 12:38:08 -07:00
|
|
|
|
|
|
|
export function fetchSoapboxConfig() {
|
|
|
|
return (dispatch, getState) => {
|
2020-04-25 21:27:02 -07:00
|
|
|
api(getState).get('/instance/soapbox.json').then(response => {
|
2020-04-01 12:38:08 -07:00
|
|
|
dispatch(importSoapboxConfig(response.data));
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch(soapboxConfigFail(error));
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function importSoapboxConfig(soapboxConfig) {
|
|
|
|
return {
|
2020-06-03 12:24:53 -07:00
|
|
|
type: SOAPBOX_CONFIG_REQUEST_SUCCESS,
|
2020-04-14 11:44:40 -07:00
|
|
|
soapboxConfig,
|
2020-04-01 12:38:08 -07:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function soapboxConfigFail(error) {
|
2020-06-09 16:53:35 -07:00
|
|
|
if (!error.response) {
|
|
|
|
console.error('soapbox.json parsing error: ' + error);
|
|
|
|
}
|
2020-04-01 12:38:08 -07:00
|
|
|
return {
|
2020-06-03 12:24:53 -07:00
|
|
|
type: SOAPBOX_CONFIG_REQUEST_FAIL,
|
2020-04-01 12:38:08 -07:00
|
|
|
error,
|
|
|
|
skipAlert: true,
|
|
|
|
};
|
2020-06-09 16:53:35 -07:00
|
|
|
}
|