IO-2733 Add Timer Started check to prevent auto refresh early.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { AlertOutlined } from "@ant-design/icons";
|
||||
import { Alert, Button, Col, notification, Row, Space } from "antd";
|
||||
import i18n from "i18next";
|
||||
import React, { useCallback, useEffect } from "react";
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -20,6 +20,7 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
|
||||
export function UpdateAlert({ updateAvailable }) {
|
||||
const { t } = useTranslation();
|
||||
const [timerStarted, setTimerStarted] = useState(false);
|
||||
const [
|
||||
timeLeft,
|
||||
{
|
||||
@@ -58,6 +59,7 @@ export function UpdateAlert({ updateAvailable }) {
|
||||
useEffect(() => {
|
||||
if (needRefresh) {
|
||||
start();
|
||||
setTimerStarted(true);
|
||||
}
|
||||
}, [start, needRefresh, offlineReady]);
|
||||
|
||||
@@ -79,10 +81,10 @@ export function UpdateAlert({ updateAvailable }) {
|
||||
placement: "bottomRight"
|
||||
});
|
||||
}
|
||||
if (needRefresh && timeLeft <= 0) {
|
||||
if (needRefresh && timerStarted && timeLeft <= 0) {
|
||||
ReloadNewVersion();
|
||||
}
|
||||
}, [timeLeft, t, needRefresh, ReloadNewVersion]);
|
||||
}, [timeLeft, t, needRefresh, ReloadNewVersion, timerStarted]);
|
||||
|
||||
if (!needRefresh) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user