mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 02:06:19 +01:00
Updated check updates logic.
This commit is contained in:
parent
d556806c64
commit
5873a56fff
@ -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;
|
||||
}
|
||||
|
||||
|
@ -8,22 +8,26 @@ import ThemeButton from 'components/settings/ThemeButton';
|
||||
import HamburgerButton from 'components/common/HamburgerButton';
|
||||
import UpdateNotice from 'components/common/UpdateNotice';
|
||||
import UserButton from 'components/settings/UserButton';
|
||||
import useUser from 'hooks/useUser';
|
||||
import { HOMEPAGE_URL } from 'lib/constants';
|
||||
import useConfig from '/hooks/useConfig';
|
||||
import useUser from 'hooks/useUser';
|
||||
import Logo from 'assets/logo.svg';
|
||||
import styles from './Header.module.css';
|
||||
|
||||
export default function Header() {
|
||||
const { user } = useUser();
|
||||
const { pathname } = useRouter();
|
||||
const { updatesDisabled } = useConfig();
|
||||
const isSharePage = pathname.includes('/share/');
|
||||
const allowUpdate = user?.is_admin && !updatesDisabled && !isSharePage;
|
||||
|
||||
return (
|
||||
<>
|
||||
<UpdateNotice />
|
||||
{allowUpdate && <UpdateNotice />}
|
||||
<header className={classNames(styles.header, 'row')}>
|
||||
<div className={styles.title}>
|
||||
<Icon icon={<Logo />} size="large" className={styles.logo} />
|
||||
<Link href={pathname.includes('/share') ? HOMEPAGE_URL : '/'}>umami</Link>
|
||||
<Link href={isSharePage ? HOMEPAGE_URL : '/'}>umami</Link>
|
||||
</div>
|
||||
<HamburgerButton />
|
||||
{user && (
|
||||
|
Loading…
Reference in New Issue
Block a user