mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Updated version checking.
This commit is contained in:
parent
1bfb26ab44
commit
c8ca0a0a56
7 changed files with 38 additions and 42 deletions
|
|
@ -1,27 +1,38 @@
|
|||
import React from 'react';
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import useVersion from 'hooks/useVersion';
|
||||
import styles from './UpdateNotice.module.css';
|
||||
import ButtonLayout from '../layout/ButtonLayout';
|
||||
import ButtonLayout from 'components/layout/ButtonLayout';
|
||||
import useStore, { checkVersion } from 'store/version';
|
||||
import { setItem } from 'lib/web';
|
||||
import { VERSION_CHECK, VERSION_URL } from 'lib/constants';
|
||||
import Button from './Button';
|
||||
import useForceUpdate from '../../hooks/useForceUpdate';
|
||||
import styles from './UpdateNotice.module.css';
|
||||
|
||||
export default function UpdateNotice() {
|
||||
const forceUpdate = useForceUpdate();
|
||||
const { hasUpdate, checked, latest, updateCheck } = useVersion(true);
|
||||
const { latest, checked, hasUpdate } = useStore();
|
||||
const [dismissed, setDismissed] = useState(false);
|
||||
|
||||
const updateCheck = useCallback(() => {
|
||||
setItem(VERSION_CHECK, { version: latest, time: Date.now() });
|
||||
}, [latest]);
|
||||
|
||||
function handleViewClick() {
|
||||
location.href = 'https://github.com/mikecao/umami/releases';
|
||||
updateCheck();
|
||||
forceUpdate();
|
||||
setDismissed(true);
|
||||
location.href = VERSION_URL;
|
||||
}
|
||||
|
||||
function handleDismissClick() {
|
||||
updateCheck();
|
||||
forceUpdate();
|
||||
setDismissed(true);
|
||||
}
|
||||
|
||||
if (!hasUpdate || checked) {
|
||||
useEffect(() => {
|
||||
if (!checked) {
|
||||
checkVersion();
|
||||
}
|
||||
}, []);
|
||||
|
||||
if (!hasUpdate || dismissed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue