diff --git a/src/constants/api.ts b/src/constants/api.ts
index f2aafdc..4771533 100644
--- a/src/constants/api.ts
+++ b/src/constants/api.ts
@@ -12,3 +12,5 @@ export const API: { [x: string]: string } = {
MODIFY_ROUTE: `${CLIENT.API_ADDR}/route/modify`,
SET_STARRED: `${CLIENT.API_ADDR}/route/star`,
};
+
+export const API_RETRY_INTERVAL = 10;
diff --git a/src/index.html b/src/index.html
index 2942898..59e7bab 100644
--- a/src/index.html
+++ b/src/index.html
@@ -4,7 +4,7 @@
-
+
Редактор маршрутов
@@ -13,7 +13,7 @@
@@ -98,13 +134,15 @@
ЗАГРУЗКА
+
+
+
Хранилище недоступно
+
Мы работаем над решением проблемы
+
+
-
-
Хранилище недоступно.
- Повторите попытку позже.
-
diff --git a/src/redux/user/sagas.ts b/src/redux/user/sagas.ts
index b608a43..c1e8e73 100644
--- a/src/redux/user/sagas.ts
+++ b/src/redux/user/sagas.ts
@@ -218,7 +218,7 @@ function* authCheckSaga() {
if (user) {
yield put(setUser(user));
- pushLoaderState(' ...готово');
+ pushLoaderState(99);
return yield call(mapInitSaga);
}
@@ -231,7 +231,7 @@ function* authCheckSaga() {
if (user) {
yield put(setUser(user));
- pushLoaderState(' ...готово');
+ pushLoaderState(99);
return yield call(mapInitSaga);
} else if (!ready) {
diff --git a/src/utils/history.ts b/src/utils/history.ts
index d85a771..1db47a8 100644
--- a/src/utils/history.ts
+++ b/src/utils/history.ts
@@ -1,4 +1,5 @@
import { history } from '$redux/store';
+import {API_RETRY_INTERVAL} from "$constants/api";
interface IUrlData {
path: string,
@@ -34,12 +35,24 @@ export const parseQuery = (queryString: string) => {
return params;
};
-export const pushLoaderState = state => {
+export const pushLoaderState = (state: number) => {
document.getElementById('loader-bar').style.width = `${state}%`;
};
+export const countDownToRefresh = (left: number = API_RETRY_INTERVAL): void => {
+ console.log('countdown');
+ if (left <= 0) return document.location.reload();
+
+ document.getElementById('loader-bar').style.width = `${(left / API_RETRY_INTERVAL) * 100}%`;
+ setTimeout(() => countDownToRefresh(left - 0.25), 1000);
+};
+
export const pushNetworkInitError = () => {
+ document.getElementById('loader-bar').classList.add('is_failed');
+ document.getElementById('loader-bar').style.width = '100%';
document.getElementById('loader-error').style.opacity = String(1);
+
+ countDownToRefresh();
};
export const copyToClipboard = str => {
@@ -52,4 +65,4 @@ export const copyToClipboard = str => {
el.select();
document.execCommand('copy');
document.body.removeChild(el);
-}
+};