mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
fixed loading error handling
This commit is contained in:
parent
dd2861fe5c
commit
0bfb1dee90
4 changed files with 79 additions and 26 deletions
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue