diff --git a/components/common/UpdateNotice.js b/components/common/UpdateNotice.js index 0bdb1041..7565d153 100644 --- a/components/common/UpdateNotice.js +++ b/components/common/UpdateNotice.js @@ -7,21 +7,21 @@ import Button from './Button'; import useForceUpdate from '../../hooks/useForceUpdate'; export default function UpdateNotice() { - const forceUpdte = useForceUpdate(); - const { hasUpdate, latest, updateCheck } = useVersion(true); + const forceUpdate = useForceUpdate(); + const { hasUpdate, checked, latest, updateCheck } = useVersion(true); function handleViewClick() { location.href = 'https://github.com/mikecao/umami/releases'; updateCheck(); - forceUpdte(); + forceUpdate(); } function handleDismissClick() { updateCheck(); - forceUpdte(); + forceUpdate(); } - if (!hasUpdate) { + if (!hasUpdate || checked) { return null; } diff --git a/hooks/useVersion.js b/hooks/useVersion.js index bec5670b..79b97a34 100644 --- a/hooks/useVersion.js +++ b/hooks/useVersion.js @@ -2,11 +2,12 @@ import { useEffect, useCallback } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { checkVersion } from 'redux/actions/app'; import { VERSION_CHECK } from 'lib/constants'; -import { setItem } from 'lib/web'; +import { getItem, setItem } from 'lib/web'; export default function useVersion(check) { const dispatch = useDispatch(); const versions = useSelector(state => state.app.versions); + const checked = versions.latest === getItem(VERSION_CHECK)?.version; const updateCheck = useCallback(() => { setItem(VERSION_CHECK, { version: versions.latest, time: Date.now() }); @@ -18,5 +19,5 @@ export default function useVersion(check) { } }, [versions, check]); - return { ...versions, updateCheck }; + return { ...versions, checked, updateCheck }; }