diff --git a/client/src/actions/index.js b/client/src/actions/index.js index aa8626a9..94830ada 100644 --- a/client/src/actions/index.js +++ b/client/src/actions/index.js @@ -139,6 +139,36 @@ export const toggleProtection = status => async (dispatch) => { } }; +export const getVersionRequest = createAction('GET_VERSION_REQUEST'); +export const getVersionFailure = createAction('GET_VERSION_FAILURE'); +export const getVersionSuccess = createAction('GET_VERSION_SUCCESS'); + +export const getVersion = () => async (dispatch) => { + dispatch(getVersionRequest()); + try { + const newVersion = await apiClient.getGlobalVersion(); + dispatch(getVersionSuccess(newVersion)); + } catch (error) { + dispatch(addErrorToast({ error })); + dispatch(getVersionFailure()); + } +}; + +export const getClientsRequest = createAction('GET_CLIENTS_REQUEST'); +export const getClientsFailure = createAction('GET_CLIENTS_FAILURE'); +export const getClientsSuccess = createAction('GET_CLIENTS_SUCCESS'); + +export const getClients = () => async (dispatch) => { + dispatch(getClientsRequest()); + try { + const clients = await apiClient.getGlobalClients(); + dispatch(getClientsSuccess(clients)); + } catch (error) { + dispatch(addErrorToast({ error })); + dispatch(getClientsFailure()); + } +}; + export const dnsStatusRequest = createAction('DNS_STATUS_REQUEST'); export const dnsStatusFailure = createAction('DNS_STATUS_FAILURE'); export const dnsStatusSuccess = createAction('DNS_STATUS_SUCCESS'); @@ -148,6 +178,8 @@ export const getDnsStatus = () => async (dispatch) => { try { const dnsStatus = await apiClient.getGlobalStatus(); dispatch(dnsStatusSuccess(dnsStatus)); + dispatch(getVersion()); + dispatch(getClients()); } catch (error) { dispatch(addErrorToast({ error })); dispatch(initSettingsFailure()); @@ -205,21 +237,6 @@ export const getStats = () => async (dispatch) => { } }; -export const getVersionRequest = createAction('GET_VERSION_REQUEST'); -export const getVersionFailure = createAction('GET_VERSION_FAILURE'); -export const getVersionSuccess = createAction('GET_VERSION_SUCCESS'); - -export const getVersion = () => async (dispatch) => { - dispatch(getVersionRequest()); - try { - const newVersion = await apiClient.getGlobalVersion(); - dispatch(getVersionSuccess(newVersion)); - } catch (error) { - dispatch(addErrorToast({ error })); - dispatch(getVersionFailure()); - } -}; - export const getTopStatsRequest = createAction('GET_TOP_STATS_REQUEST'); export const getTopStatsFailure = createAction('GET_TOP_STATS_FAILURE'); export const getTopStatsSuccess = createAction('GET_TOP_STATS_SUCCESS'); @@ -665,18 +682,3 @@ export const toggleDhcp = config => async (dispatch) => { } } }; - -export const getClientsRequest = createAction('GET_CLIENTS_REQUEST'); -export const getClientsFailure = createAction('GET_CLIENTS_FAILURE'); -export const getClientsSuccess = createAction('GET_CLIENTS_SUCCESS'); - -export const getClients = () => async (dispatch) => { - dispatch(getClientsRequest()); - try { - const clients = await apiClient.getGlobalClients(); - dispatch(getClientsSuccess(clients)); - } catch (error) { - dispatch(addErrorToast({ error })); - dispatch(getClientsFailure()); - } -}; diff --git a/client/src/components/App/index.js b/client/src/components/App/index.js index fdc4cc2a..545d5007 100644 --- a/client/src/components/App/index.js +++ b/client/src/components/App/index.js @@ -25,8 +25,6 @@ import i18n from '../../i18n'; class App extends Component { componentDidMount() { this.props.getDnsStatus(); - this.props.getVersion(); - this.props.getClients(); } componentDidUpdate(prevProps) { @@ -106,10 +104,8 @@ App.propTypes = { dashboard: PropTypes.object, isCoreRunning: PropTypes.bool, error: PropTypes.string, - getVersion: PropTypes.func, changeLanguage: PropTypes.func, encryption: PropTypes.object, - getClients: PropTypes.func, }; export default withNamespaces()(App);