From 0668cc786fcaf1cd0f79e405a9827208a42d096c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 23 Aug 2020 15:32:44 -0500 Subject: [PATCH] Refactor fetchSoapboxConfig() --- app/soapbox/actions/soapbox.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/soapbox/actions/soapbox.js b/app/soapbox/actions/soapbox.js index 6430e90c3..12f7f410d 100644 --- a/app/soapbox/actions/soapbox.js +++ b/app/soapbox/actions/soapbox.js @@ -9,18 +9,20 @@ export function fetchSoapboxConfig() { if (response.data.soapbox_fe) { dispatch(importSoapboxConfig(response.data.soapbox_fe)); } else { - api(getState).get('/instance/soapbox.json').then(response => { - dispatch(importSoapboxConfig(response.data)); - }).catch(error => { - dispatch(soapboxConfigFail(error)); - }); + dispatch(fetchSoapboxJson()); } }).catch(error => { - api(getState).get('/instance/soapbox.json').then(response => { - dispatch(importSoapboxConfig(response.data)); - }).catch(error => { - dispatch(soapboxConfigFail(error)); - }); + dispatch(fetchSoapboxJson()); + }); + }; +} + +export function fetchSoapboxJson() { + return (dispatch, getState) => { + api(getState).get('/instance/soapbox.json').then(response => { + dispatch(importSoapboxConfig(response.data)); + }).catch(error => { + dispatch(soapboxConfigFail(error)); }); }; }