Check that soapbox.json is really an object before importing, fixes #376
This commit is contained in:
parent
c8e6bd9540
commit
cd5ee4837c
|
@ -40,8 +40,9 @@ export function fetchSoapboxConfig() {
|
||||||
|
|
||||||
export function fetchSoapboxJson() {
|
export function fetchSoapboxJson() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
api(getState).get('/instance/soapbox.json').then(response => {
|
api(getState).get('/instance/soapbox.json').then(({ data }) => {
|
||||||
dispatch(importSoapboxConfig(response.data));
|
if (!isObject(data)) throw 'soapbox.json failed';
|
||||||
|
dispatch(importSoapboxConfig(data));
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
dispatch(soapboxConfigFail(error));
|
dispatch(soapboxConfigFail(error));
|
||||||
});
|
});
|
||||||
|
@ -56,12 +57,14 @@ export function importSoapboxConfig(soapboxConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function soapboxConfigFail(error) {
|
export function soapboxConfigFail(error) {
|
||||||
if (!error.response) {
|
|
||||||
console.error('Unable to obtain soapbox configuration: ' + error);
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
type: SOAPBOX_CONFIG_REQUEST_FAIL,
|
type: SOAPBOX_CONFIG_REQUEST_FAIL,
|
||||||
error,
|
error,
|
||||||
skipAlert: true,
|
skipAlert: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://stackoverflow.com/a/46663081
|
||||||
|
function isObject(o) {
|
||||||
|
return o instanceof Object && o.constructor === Object;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue