import React, { useEffect, useRef, useState } from 'react' import { Button, Modal } from '@janhq/joi' import { check, Update } from '@tauri-apps/plugin-updater' import { useAtom } from 'jotai' import { useGetLatestRelease } from '@/hooks/useGetLatestRelease' import { MarkdownTextMessage } from '@/screens/Thread/ThreadCenterPanel/TextMessage/MarkdownTextMessage' import LogoMark from '../Brand/Logo/Mark' import { appUpdateAvailableAtom } from '@/helpers/atoms/App.atom' const ModalAppUpdaterChangelog = () => { const [appUpdateAvailable, setAppUpdateAvailable] = useAtom( appUpdateAvailableAtom ) const updaterRef = useRef(null) const [open, setOpen] = useState(appUpdateAvailable) useEffect(() => { setOpen(appUpdateAvailable) }, [appUpdateAvailable]) const beta = VERSION.includes('beta') const nightly = VERSION.includes('-') const checkForUpdate = async () => { const update = await check() if (update) { setAppUpdateAvailable(true) updaterRef.current = update } } useEffect(() => { checkForUpdate() }, []) const { release } = useGetLatestRelease(beta ? true : false) return (
App Update
{!nightly && (

Version {release?.name} is available and ready to install.

)} } open={open} onOpenChange={() => setOpen(!open)} content={
{nightly ? (

You are using a nightly build. This version is built from the latest development branch and may not have release notes.

) : ( <>
)}
} /> ) } export default ModalAppUpdaterChangelog