mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +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';
|
import useForceUpdate from '../../hooks/useForceUpdate';
|
||||||
|
|
||||||
export default function UpdateNotice() {
|
export default function UpdateNotice() {
|
||||||
const forceUpdte = useForceUpdate();
|
const forceUpdate = useForceUpdate();
|
||||||
const { hasUpdate, latest, updateCheck } = useVersion(true);
|
const { hasUpdate, checked, latest, updateCheck } = useVersion(true);
|
||||||
|
|
||||||
function handleViewClick() {
|
function handleViewClick() {
|
||||||
location.href = 'https://github.com/mikecao/umami/releases';
|
location.href = 'https://github.com/mikecao/umami/releases';
|
||||||
updateCheck();
|
updateCheck();
|
||||||
forceUpdte();
|
forceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDismissClick() {
|
function handleDismissClick() {
|
||||||
updateCheck();
|
updateCheck();
|
||||||
forceUpdte();
|
forceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasUpdate) {
|
if (!hasUpdate || checked) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,11 +2,12 @@ import { useEffect, useCallback } from 'react';
|
|||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import { checkVersion } from 'redux/actions/app';
|
import { checkVersion } from 'redux/actions/app';
|
||||||
import { VERSION_CHECK } from 'lib/constants';
|
import { VERSION_CHECK } from 'lib/constants';
|
||||||
import { setItem } from 'lib/web';
|
import { getItem, setItem } from 'lib/web';
|
||||||
|
|
||||||
export default function useVersion(check) {
|
export default function useVersion(check) {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const versions = useSelector(state => state.app.versions);
|
const versions = useSelector(state => state.app.versions);
|
||||||
|
const checked = versions.latest === getItem(VERSION_CHECK)?.version;
|
||||||
|
|
||||||
const updateCheck = useCallback(() => {
|
const updateCheck = useCallback(() => {
|
||||||
setItem(VERSION_CHECK, { version: versions.latest, time: Date.now() });
|
setItem(VERSION_CHECK, { version: versions.latest, time: Date.now() });
|
||||||
@ -18,5 +19,5 @@ export default function useVersion(check) {
|
|||||||
}
|
}
|
||||||
}, [versions, check]);
|
}, [versions, check]);
|
||||||
|
|
||||||
return { ...versions, updateCheck };
|
return { ...versions, checked, updateCheck };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user