mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 07:13:37 +01:00
Fix version check.
This commit is contained in:
parent
b35c5b57da
commit
48a1994219
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user