mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-21 06:49:37 +00:00
Floating menu option (#726)
* Add floating menu * Fix * Updates * Add auto-queue change test * Fix
This commit is contained in:
committed by
Chenlei Hu
parent
73a7f7dae0
commit
2d1ff64951
41
src/services/autoQueueService.ts
Normal file
41
src/services/autoQueueService.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
useQueueSettingsStore,
|
||||
useQueuePendingTaskCountStore
|
||||
} from '@/stores/queueStore'
|
||||
import { app } from '@/scripts/app'
|
||||
import { api } from '@/scripts/api'
|
||||
|
||||
export function setupAutoQueueHandler() {
|
||||
const queueCountStore = useQueuePendingTaskCountStore()
|
||||
const queueSettingsStore = useQueueSettingsStore()
|
||||
|
||||
let graphHasChanged = false
|
||||
let internalCount = 0 // Use an internal counter here so it is instantly updated when re-queuing
|
||||
api.addEventListener('graphChanged', () => {
|
||||
if (queueSettingsStore.mode === 'change') {
|
||||
if (internalCount) {
|
||||
graphHasChanged = true
|
||||
} else {
|
||||
graphHasChanged = false
|
||||
app.queuePrompt(0, queueSettingsStore.batchCount)
|
||||
internalCount++
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
queueCountStore.$subscribe(
|
||||
() => {
|
||||
internalCount = queueCountStore.count
|
||||
if (!internalCount && !app.lastExecutionError) {
|
||||
if (
|
||||
queueSettingsStore.mode === 'instant' ||
|
||||
(queueSettingsStore.mode === 'change' && graphHasChanged)
|
||||
) {
|
||||
graphHasChanged = false
|
||||
app.queuePrompt(0, queueSettingsStore.batchCount)
|
||||
}
|
||||
}
|
||||
},
|
||||
{ detached: true }
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user