- client: check version on update before page reload

This commit is contained in:
Ildar Kamalov 2019-06-05 16:11:26 +03:00 committed by Simon Zolin
parent a165410c9f
commit 10a0873bc8
1 changed files with 10 additions and 4 deletions

View File

@ -160,7 +160,9 @@ export const getUpdateRequest = createAction('GET_UPDATE_REQUEST');
export const getUpdateFailure = createAction('GET_UPDATE_FAILURE'); export const getUpdateFailure = createAction('GET_UPDATE_FAILURE');
export const getUpdateSuccess = createAction('GET_UPDATE_SUCCESS'); export const getUpdateSuccess = createAction('GET_UPDATE_SUCCESS');
export const getUpdate = () => async (dispatch) => { export const getUpdate = () => async (dispatch, getState) => {
const { dnsVersion } = getState().dashboard;
dispatch(getUpdateRequest()); dispatch(getUpdateRequest());
try { try {
await apiClient.getUpdate(); await apiClient.getUpdate();
@ -185,10 +187,14 @@ export const getUpdate = () => async (dispatch) => {
axios.get('control/status') axios.get('control/status')
.then((response) => { .then((response) => {
rmTimeout(timeout); rmTimeout(timeout);
if (response) { if (response && response.status === 200) {
const responseVersion = response.data && response.data.version;
if (dnsVersion !== responseVersion) {
dispatch(getUpdateSuccess()); dispatch(getUpdateSuccess());
window.location.reload(true); window.location.reload(true);
} }
}
timeout = setRecursiveTimeout(CHECK_TIMEOUT, count += 1); timeout = setRecursiveTimeout(CHECK_TIMEOUT, count += 1);
}) })
.catch(() => { .catch(() => {