mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-04 15:10:06 +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 _ from 'es-toolkit/compat'
|
||||
import { useAsyncState } from '@vueuse/core'
|
||||
import { until, useAsyncState } from '@vueuse/core'
|
||||
import { defineStore } from 'pinia'
|
||||
import { compare, valid } from 'semver'
|
||||
import { ref } from 'vue'
|
||||
@@ -71,10 +71,15 @@ export const useSettingStore = defineStore('setting', () => {
|
||||
{ immediate: false }
|
||||
)
|
||||
|
||||
async function load() {
|
||||
if (!isReady.value && !isLoading.value) {
|
||||
return loadSettingValues()
|
||||
async function load(): Promise<void> {
|
||||
if (isReady.value) return
|
||||
|
||||
if (isLoading.value) {
|
||||
await until(isLoading).toBe(false)
|
||||
return
|
||||
}
|
||||
|
||||
await loadSettingValues()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import _ from 'es-toolkit/compat'
|
||||
import { useAsyncState } from '@vueuse/core'
|
||||
import { until, useAsyncState } from '@vueuse/core'
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, markRaw, ref, shallowRef, watch } from 'vue'
|
||||
import type { Raw } from 'vue'
|
||||
@@ -558,10 +558,15 @@ export const useWorkflowStore = defineStore('workflow', () => {
|
||||
return executeSyncWorkflows(0, dir)
|
||||
}
|
||||
|
||||
async function loadWorkflows() {
|
||||
if (!isSyncReady.value && !isSyncLoading.value) {
|
||||
return syncWorkflows()
|
||||
async function loadWorkflows(): Promise<void> {
|
||||
if (isSyncReady.value) return
|
||||
|
||||
if (isSyncLoading.value) {
|
||||
await until(isSyncLoading).toBe(false)
|
||||
return
|
||||
}
|
||||
|
||||
await syncWorkflows()
|
||||
}
|
||||
|
||||
const bookmarkStore = useWorkflowBookmarkStore()
|
||||
|
||||
Reference in New Issue
Block a user