chore: cleanup
This commit is contained in:
parent
2c52f297cb
commit
be9d1bc874
|
@ -9,9 +9,7 @@ export function update(win: Electron.BrowserWindow) {
|
|||
|
||||
// When set to false, the update download will be triggered through the API
|
||||
autoUpdater.autoDownload = false
|
||||
|
||||
autoUpdater.disableWebInstaller = false
|
||||
|
||||
autoUpdater.allowDowngrade = false
|
||||
|
||||
// start check
|
||||
|
@ -27,6 +25,11 @@ export function update(win: Electron.BrowserWindow) {
|
|||
|
||||
// Checking for updates
|
||||
ipcMain.handle('check-update', async () => {
|
||||
if (!app.isPackaged) {
|
||||
const error = new Error('The update feature is only available after the package.')
|
||||
return { message: error.message, error }
|
||||
}
|
||||
|
||||
try {
|
||||
return await autoUpdater.checkForUpdatesAndNotify()
|
||||
} catch (error) {
|
||||
|
@ -52,6 +55,7 @@ export function update(win: Electron.BrowserWindow) {
|
|||
}
|
||||
)
|
||||
})
|
||||
|
||||
// Install now
|
||||
ipcMain.handle('quit-and-install', () => {
|
||||
autoUpdater.quitAndInstall(false, true)
|
||||
|
|
|
@ -10,7 +10,7 @@ const Update = () => {
|
|||
const [updateAvailable, setUpdateAvailable] = useState(false)
|
||||
const [versionInfo, setVersionInfo] = useState<VersionInfo>()
|
||||
const [updateError, setUpdateError] = useState<ErrorType>()
|
||||
const [progressInfo, setProgressInfo] = useState<ProgressInfo>()
|
||||
const [progressInfo, setProgressInfo] = useState<Partial<ProgressInfo>>()
|
||||
const [modalOpen, setModalOpen] = useState<boolean>(false)
|
||||
const [modalBtn, setModalBtn] = useState<{
|
||||
cancelText?: string
|
||||
|
@ -45,7 +45,6 @@ const Update = () => {
|
|||
...state,
|
||||
cancelText: 'Cancel',
|
||||
okText: 'Update',
|
||||
onCancel: () => setModalOpen(false),
|
||||
onOk: () => ipcRenderer.invoke('start-download'),
|
||||
}))
|
||||
setUpdateAvailable(true)
|
||||
|
@ -56,13 +55,11 @@ const Update = () => {
|
|||
}, [])
|
||||
|
||||
const onUpdateError = useCallback((_event: Electron.IpcRendererEvent, arg1: ErrorType) => {
|
||||
console.error('arg1.error',arg1.error)
|
||||
setUpdateAvailable(false)
|
||||
setUpdateError(arg1)
|
||||
}, [])
|
||||
|
||||
const onDownloadProgress = useCallback((_event: Electron.IpcRendererEvent, arg1: ProgressInfo) => {
|
||||
console.log(arg1)
|
||||
setUpdateAvailable(true)
|
||||
setProgressInfo(arg1)
|
||||
}, [])
|
||||
|
@ -105,8 +102,13 @@ const Update = () => {
|
|||
footer={isUpdate ? /* hide footer */null : undefined}
|
||||
>
|
||||
<div className={styles.modalslot}>
|
||||
{
|
||||
isUpdate
|
||||
{updateError
|
||||
? (
|
||||
<div className='update-error'>
|
||||
<p>Error downloading the latest version.</p>
|
||||
<p>{updateError.message}</p>
|
||||
</div>
|
||||
) : isUpdate
|
||||
? (
|
||||
<div>
|
||||
<div>The last version is: v{versionInfo.newVersion}</div>
|
||||
|
@ -119,18 +121,7 @@ const Update = () => {
|
|||
</div>
|
||||
</div>
|
||||
)
|
||||
: updateError
|
||||
? (
|
||||
<div className='update-error'>
|
||||
<p>Error downloading the latest version.</p>
|
||||
<p>{updateError.message}</p>
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
<div>The last version is: v{versionInfo?.version}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
: <div>Checking...</div>}
|
||||
</div>
|
||||
</Modal>
|
||||
<button disabled={checking} onClick={checkUpdate}>
|
||||
|
|
Loading…
Reference in New Issue