mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-28 18:54:09 +00:00
[Desktop] Add toasts for update check (#3723)
Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import log from 'loglevel'
|
||||
|
||||
import { PYTHON_MIRROR } from '@/constants/uvMirrors'
|
||||
import { t } from '@/i18n'
|
||||
import { app } from '@/scripts/app'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
import { useToastStore } from '@/stores/toastStore'
|
||||
import { useWorkflowStore } from '@/stores/workflowStore'
|
||||
import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'
|
||||
import { checkMirrorReachable } from '@/utils/networkUtil'
|
||||
@@ -12,6 +15,7 @@ import { checkMirrorReachable } from '@/utils/networkUtil'
|
||||
const electronAPI = getElectronAPI()
|
||||
const desktopAppVersion = await electronAPI.getElectronVersion()
|
||||
const workflowStore = useWorkflowStore()
|
||||
const toastStore = useToastStore()
|
||||
|
||||
const onChangeRestartApp = (newValue: string, oldValue: string) => {
|
||||
// Add a delay to allow changes to take effect before restarting.
|
||||
@@ -163,19 +167,48 @@ import { checkMirrorReachable } from '@/utils/networkUtil'
|
||||
label: 'Check for Updates',
|
||||
icon: 'pi pi-sync',
|
||||
async function() {
|
||||
const updateAvailable = await electronAPI.checkForUpdates({
|
||||
disableUpdateReadyAction: true
|
||||
})
|
||||
if (updateAvailable.isUpdateAvailable) {
|
||||
const version = updateAvailable.version
|
||||
try {
|
||||
const updateInfo = await electronAPI.checkForUpdates({
|
||||
disableUpdateReadyAction: true
|
||||
})
|
||||
|
||||
if (!updateInfo.isUpdateAvailable) {
|
||||
toastStore.add({
|
||||
severity: 'info',
|
||||
summary: t('desktopUpdate.noUpdateFound'),
|
||||
life: 5_000
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const proceed = await useDialogService().confirm({
|
||||
title: t('desktopUpdate.updateFoundTitle', { version }),
|
||||
title: t('desktopUpdate.updateFoundTitle', {
|
||||
version: updateInfo.version
|
||||
}),
|
||||
message: t('desktopUpdate.updateAvailableMessage'),
|
||||
type: 'default'
|
||||
})
|
||||
if (proceed) {
|
||||
electronAPI.restartAndInstall()
|
||||
try {
|
||||
electronAPI.restartAndInstall()
|
||||
} catch (error) {
|
||||
log.error('Error installing update:', error)
|
||||
toastStore.add({
|
||||
severity: 'error',
|
||||
summary: t('g.error'),
|
||||
detail: t('desktopUpdate.errorInstallingUpdate'),
|
||||
life: 10_000
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
log.error('Error checking for updates:', error)
|
||||
toastStore.add({
|
||||
severity: 'error',
|
||||
summary: t('g.error'),
|
||||
detail: t('desktopUpdate.errorCheckingUpdate'),
|
||||
life: 10_000
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user