+ client: handle update

This commit is contained in:
Ildar Kamalov
2019-05-16 17:24:30 +03:00
committed by Simon Zolin
parent 068072bc5a
commit cb3f7f2834
8 changed files with 155 additions and 18 deletions

View File

@@ -4,7 +4,7 @@ import { t } from 'i18next';
import { showLoading, hideLoading } from 'react-redux-loading-bar';
import { normalizeHistory, normalizeFilteringStatus, normalizeLogs, normalizeTextarea } from '../helpers/helpers';
import { SETTINGS_NAMES } from '../helpers/constants';
import { SETTINGS_NAMES, CHECK_TIMEOUT } from '../helpers/constants';
import Api from '../api/Api';
const apiClient = new Api();
@@ -154,6 +154,29 @@ export const getVersion = () => async (dispatch) => {
}
};
export const getUpdateRequest = createAction('GET_UPDATE_REQUEST');
export const getUpdateFailure = createAction('GET_UPDATE_FAILURE');
export const getUpdateSuccess = createAction('GET_UPDATE_SUCCESS');
export const getUpdate = () => async (dispatch) => {
dispatch(getUpdateRequest());
try {
await apiClient.getUpdate();
const timer = setInterval(async () => {
const dnsStatus = await apiClient.getGlobalStatus();
if (dnsStatus) {
clearInterval(timer);
dispatch(getUpdateSuccess());
window.location.reload(true);
}
}, CHECK_TIMEOUT);
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(getUpdateFailure());
}
};
export const getClientsRequest = createAction('GET_CLIENTS_REQUEST');
export const getClientsFailure = createAction('GET_CLIENTS_FAILURE');
export const getClientsSuccess = createAction('GET_CLIENTS_SUCCESS');