IO-2733 Add loading state and further delay reload.
This commit is contained in:
@@ -21,6 +21,7 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
export function UpdateAlert({ updateAvailable }) {
|
export function UpdateAlert({ updateAvailable }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [timerStarted, setTimerStarted] = useState(false);
|
const [timerStarted, setTimerStarted] = useState(false);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
const [
|
const [
|
||||||
timeLeft,
|
timeLeft,
|
||||||
{
|
{
|
||||||
@@ -50,10 +51,11 @@ export function UpdateAlert({ updateAvailable }) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const ReloadNewVersion = useCallback(() => {
|
const ReloadNewVersion = useCallback(() => {
|
||||||
|
setLoading(true);
|
||||||
updateServiceWorker(true);
|
updateServiceWorker(true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
}, 2000);
|
}, 5000);
|
||||||
}, [updateServiceWorker]);
|
}, [updateServiceWorker]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -115,7 +117,7 @@ export function UpdateAlert({ updateAvailable }) {
|
|||||||
<Button onClick={() => window.open("https://imex-online.noticeable.news/", "_blank")}>
|
<Button onClick={() => window.open("https://imex-online.noticeable.news/", "_blank")}>
|
||||||
{i18n.t("general.actions.viewreleasenotes")}
|
{i18n.t("general.actions.viewreleasenotes")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="primary" onClick={() => ReloadNewVersion()}>
|
<Button loading={loading} type="primary" onClick={() => ReloadNewVersion()}>
|
||||||
{i18n.t("general.actions.refresh")} {`(${(timeLeft / 1000).toFixed(0)} s)`}
|
{i18n.t("general.actions.refresh")} {`(${(timeLeft / 1000).toFixed(0)} s)`}
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={() => start(300000)}>{i18n.t("general.actions.delay")}</Button>
|
<Button onClick={() => start(300000)}>{i18n.t("general.actions.delay")}</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user