mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-25 17:24:07 +00:00
fix(node-help): refetch on locale or node change with last-write-wins guard
- Watch both currentHelpNode and i18n.locale - Add requestId guard to ignore stale fetches - Keep UX responsive without debounce This eliminates the help locale race and updates content when switching language while help is open.
This commit is contained in:
@@ -29,25 +29,32 @@ export const useNodeHelpStore = defineStore('nodeHelp', () => {
|
||||
return getNodeHelpBaseUrl(node)
|
||||
})
|
||||
|
||||
// Watch for help node changes and fetch its docs markdown
|
||||
watch(
|
||||
() => currentHelpNode.value,
|
||||
async (node) => {
|
||||
helpContent.value = ''
|
||||
errorMsg.value = null
|
||||
let lastRequestId = 0
|
||||
async function refreshHelp(node: ComfyNodeDefImpl | null, locale: string) {
|
||||
helpContent.value = ''
|
||||
errorMsg.value = null
|
||||
|
||||
if (node) {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const locale = i18n.global.locale.value || 'en'
|
||||
helpContent.value = await nodeHelpService.fetchNodeHelp(node, locale)
|
||||
} catch (e: any) {
|
||||
errorMsg.value = e.message
|
||||
helpContent.value = node.description || ''
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
if (!node) return
|
||||
|
||||
const requestId = ++lastRequestId
|
||||
isLoading.value = true
|
||||
try {
|
||||
const text = await nodeHelpService.fetchNodeHelp(node, locale)
|
||||
if (requestId !== lastRequestId) return
|
||||
helpContent.value = text
|
||||
} catch (e: any) {
|
||||
if (requestId !== lastRequestId) return
|
||||
errorMsg.value = e.message
|
||||
helpContent.value = node.description || ''
|
||||
} finally {
|
||||
if (requestId === lastRequestId) isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [currentHelpNode.value, i18n.global.locale.value] as const,
|
||||
async ([node, locale]) => {
|
||||
await refreshHelp(node, locale || 'en')
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user