Refactor Comfy version retrieval and update changelog version description

This commit is contained in:
christian-byrne
2025-01-18 13:04:22 -07:00
parent 86789ceb9d
commit 11c46ea62d
3 changed files with 16 additions and 15 deletions

View File

@@ -73,12 +73,11 @@ import {
} from '@/stores/modelToNodeStore'
import { ComfyNodeDefImpl, useNodeDefStore } from '@/stores/nodeDefStore'
import { useSettingStore } from '@/stores/settingStore'
import { useSystemStatsStore } from '@/stores/systemStatsStore'
import { useWorkflowStore } from '@/stores/workflowStore'
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
import { useWorkspaceStore } from '@/stores/workspaceStore'
import type { RenderedTreeExplorerNode } from '@/types/treeExplorerTypes'
import { electronAPI, isElectron, isVersionLessThan } from '@/utils/envUtil'
import { getComfyVersion, isVersionLessThan } from '@/utils/envUtil'
const emit = defineEmits(['ready'])
const canvasRef = ref<HTMLCanvasElement | null>(null)
@@ -282,28 +281,21 @@ const persistCurrentWorkflow = () => {
}
}
const getComfyVersion = () => {
if (isElectron()) return electronAPI().getComfyUIVersion()
return useSystemStatsStore()?.systemStats?.system?.comfyui_version ?? ''
}
const stopWatchChangeLog = watch(
() => workflowStore.activeWorkflow,
() => {
async () => {
if (!comfyAppReady.value) return
const isDisabled = settingStore.get('Comfy.ShowChangeLog') === false
if (isDisabled || !changelog) {
if (!changelog || settingStore.get('Comfy.ShowChangeLog') === false) {
stopWatchChangeLog()
return
}
const workflow = workflowStore.activeWorkflow
const activeState = workflow?.activeState
const comfyVersion = getComfyVersion()
const comfyVersion = getComfyVersion() // TODO: initialize/fetch somewhere else
if (!workflow || !activeState || !comfyVersion) return
// Just checking if temporary is not enough bc doesn't account for duplicate feature
// Just checking if workflow temporary is not enough bc of Duplicate feature
const isBlank = !workflow.isPersisted && activeState.nodes?.length === 0
if (!isBlank) return

View File

@@ -719,7 +719,7 @@ export const CORE_SETTINGS: SettingParams[] = [
},
{
id: 'Comfy.LastChangelogVersion',
name: 'The version of ComfyUI on which the last changelog was shown',
name: 'Last shown changelog version',
type: 'hidden',
defaultValue: '0.0.0',
versionAdded: '1.7.15'

View File

@@ -3,6 +3,8 @@ import {
ElectronContextMenuOptions
} from '@comfyorg/comfyui-electron-types'
import { useSystemStatsStore } from '@/stores/systemStatsStore'
export function isElectron() {
return 'electronAPI' in window && window.electronAPI !== undefined
}
@@ -19,7 +21,7 @@ const normalizeVersion = (version: string) => {
return version
.split('.')
.map(Number)
.filter((v) => !Number.isNaN(v))
.filter((n): n is number => !Number.isNaN(n))
}
export function isVersionLessThan(versionA: string, versionB: string) {
@@ -38,3 +40,10 @@ export function isVersionLessThan(versionA: string, versionB: string) {
return false
}
export function getComfyVersion() {
if (isElectron()) return electronAPI().getComfyUIVersion()
const store = useSystemStatsStore()
store.fetchSystemStats()
return store.systemStats?.system?.comfyui_version ?? ''
}