mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 06:07:17 +01:00
Updated check updates logic.
This commit is contained in:
parent
d556806c64
commit
5873a56fff
2 changed files with 9 additions and 10 deletions
|
|
@ -6,15 +6,10 @@ import { setItem } from 'lib/web';
|
|||
import { REPO_URL, VERSION_CHECK } from 'lib/constants';
|
||||
import Button from './Button';
|
||||
import styles from './UpdateNotice.module.css';
|
||||
import useUser from 'hooks/useUser';
|
||||
import useConfig from 'hooks/useConfig';
|
||||
|
||||
export default function UpdateNotice() {
|
||||
const { user } = useUser();
|
||||
const { updatesDisabled } = useConfig();
|
||||
const { latest, checked, hasUpdate, releaseUrl } = useStore();
|
||||
const [dismissed, setDismissed] = useState(false);
|
||||
const allowCheck = user?.is_admin && !updatesDisabled;
|
||||
|
||||
const updateCheck = useCallback(() => {
|
||||
setItem(VERSION_CHECK, { version: latest, time: Date.now() });
|
||||
|
|
@ -32,12 +27,12 @@ export default function UpdateNotice() {
|
|||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!checked && allowCheck) {
|
||||
if (!checked) {
|
||||
checkVersion();
|
||||
}
|
||||
}, [checked]);
|
||||
|
||||
if (!hasUpdate || dismissed || !allowCheck) {
|
||||
if (!hasUpdate || dismissed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue