From 398632001a589a20cecb4416dfd261be21e18959 Mon Sep 17 00:00:00 2001 From: Attila Gazso Date: Fri, 24 Jun 2022 15:21:59 +0200 Subject: [PATCH] fix: check desktop version only once (#441) --- src/layout/Dashboard.tsx | 58 +++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/layout/Dashboard.tsx b/src/layout/Dashboard.tsx index 73cfd4b..7947f48 100644 --- a/src/layout/Dashboard.tsx +++ b/src/layout/Dashboard.tsx @@ -1,6 +1,6 @@ import { Button, CircularProgress, Container, IconButton } from '@material-ui/core' import { createStyles, makeStyles, Theme } from '@material-ui/core/styles' -import React, { ReactElement, useContext } from 'react' +import React, { ReactElement, useContext, useEffect } from 'react' import { useSnackbar } from 'notistack' import CloseIcon from 'remixicon-react/CloseCircleLineIcon' import ErrorBoundary from '../components/ErrorBoundary' @@ -33,33 +33,35 @@ const Dashboard = (props: Props): ReactElement => { const { newBeeDesktopVersion } = useNewBeeDesktopVersion(isBeeDesktop) const { enqueueSnackbar, closeSnackbar } = useSnackbar() - if (newBeeDesktopVersion !== '') { - enqueueSnackbar(`There is new Swarm Dashboard version ${newBeeDesktopVersion}!`, { - variant: 'warning', - preventDuplicate: true, - key: 'desktopNewVersion', - persist: true, - action: key => ( - - - { - closeSnackbar(key) - }} - > - - - - ), - }) - } + useEffect(() => { + if (newBeeDesktopVersion !== '') { + enqueueSnackbar(`There is new Swarm Dashboard version ${newBeeDesktopVersion}!`, { + variant: 'warning', + preventDuplicate: true, + key: 'desktopNewVersion', + persist: true, + action: key => ( + + + { + closeSnackbar(key) + }} + > + + + + ), + }) + } + }, [enqueueSnackbar, closeSnackbar, newBeeDesktopVersion]) const content = ( <>