mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 18:52:19 +00:00
fix: await concurrent calls to load() in settingStore and workflowStore
- Return early if already loaded (isReady/isSyncReady) - Use VueUse `until()` to await in-progress loading instead of returning undefined - Ensures all callers properly wait for initialization to complete Amp-Thread-ID: https://ampcode.com/threads/T-019bfdee-7166-76c3-8c5f-473717a9148b Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { retry } from 'es-toolkit'
|
import { retry } from 'es-toolkit'
|
||||||
import _ from 'es-toolkit/compat'
|
import _ from 'es-toolkit/compat'
|
||||||
import { useAsyncState } from '@vueuse/core'
|
import { until, useAsyncState } from '@vueuse/core'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { compare, valid } from 'semver'
|
import { compare, valid } from 'semver'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
@@ -71,10 +71,15 @@ export const useSettingStore = defineStore('setting', () => {
|
|||||||
{ immediate: false }
|
{ immediate: false }
|
||||||
)
|
)
|
||||||
|
|
||||||
async function load() {
|
async function load(): Promise<void> {
|
||||||
if (!isReady.value && !isLoading.value) {
|
if (isReady.value) return
|
||||||
return loadSettingValues()
|
|
||||||
|
if (isLoading.value) {
|
||||||
|
await until(isLoading).toBe(false)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await loadSettingValues()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import _ from 'es-toolkit/compat'
|
import _ from 'es-toolkit/compat'
|
||||||
import { useAsyncState } from '@vueuse/core'
|
import { until, useAsyncState } from '@vueuse/core'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { computed, markRaw, ref, shallowRef, watch } from 'vue'
|
import { computed, markRaw, ref, shallowRef, watch } from 'vue'
|
||||||
import type { Raw } from 'vue'
|
import type { Raw } from 'vue'
|
||||||
@@ -558,10 +558,15 @@ export const useWorkflowStore = defineStore('workflow', () => {
|
|||||||
return executeSyncWorkflows(0, dir)
|
return executeSyncWorkflows(0, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadWorkflows() {
|
async function loadWorkflows(): Promise<void> {
|
||||||
if (!isSyncReady.value && !isSyncLoading.value) {
|
if (isSyncReady.value) return
|
||||||
return syncWorkflows()
|
|
||||||
|
if (isSyncLoading.value) {
|
||||||
|
await until(isSyncLoading).toBe(false)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await syncWorkflows()
|
||||||
}
|
}
|
||||||
|
|
||||||
const bookmarkStore = useWorkflowBookmarkStore()
|
const bookmarkStore = useWorkflowBookmarkStore()
|
||||||
|
|||||||
Reference in New Issue
Block a user