Refactor fetchSoapboxConfig()

This commit is contained in:
Alex Gleason 2020-08-23 15:32:44 -05:00
parent b7a6d7d261
commit 0668cc786f
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -9,18 +9,20 @@ export function fetchSoapboxConfig() {
if (response.data.soapbox_fe) { if (response.data.soapbox_fe) {
dispatch(importSoapboxConfig(response.data.soapbox_fe)); dispatch(importSoapboxConfig(response.data.soapbox_fe));
} else { } else {
api(getState).get('/instance/soapbox.json').then(response => { dispatch(fetchSoapboxJson());
dispatch(importSoapboxConfig(response.data));
}).catch(error => {
dispatch(soapboxConfigFail(error));
});
} }
}).catch(error => { }).catch(error => {
api(getState).get('/instance/soapbox.json').then(response => { dispatch(fetchSoapboxJson());
dispatch(importSoapboxConfig(response.data)); });
}).catch(error => { };
dispatch(soapboxConfigFail(error)); }
});
export function fetchSoapboxJson() {
return (dispatch, getState) => {
api(getState).get('/instance/soapbox.json').then(response => {
dispatch(importSoapboxConfig(response.data));
}).catch(error => {
dispatch(soapboxConfigFail(error));
}); });
}; };
} }