From 954504de8d732d711bf680087f880af1c82a85ed Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 13 Sep 2024 09:56:41 -0700 Subject: [PATCH] IO-2733 Add Timer Started check to prevent auto refresh early. --- .../components/update-alert/update-alert.component.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/src/components/update-alert/update-alert.component.jsx b/client/src/components/update-alert/update-alert.component.jsx index 1760ddd0c..dee86d7ad 100644 --- a/client/src/components/update-alert/update-alert.component.jsx +++ b/client/src/components/update-alert/update-alert.component.jsx @@ -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;