mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-19 06:20:10 +00:00
[lint] Enforce @typescript-eslint/no-floating-promises (#3402)
This commit is contained in:
@@ -41,9 +41,7 @@ export const useNodeDragAndDrop = <T>(
|
||||
if (!isDraggingValidFiles(e)) return false
|
||||
|
||||
const files = filterFiles(e.dataTransfer!.files)
|
||||
onDrop(files).then((results) => {
|
||||
if (!results?.length) return
|
||||
})
|
||||
void onDrop(files)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,7 @@ export const useNodePaste = <T>(
|
||||
|
||||
const paste = allow_batch ? filteredFiles : filteredFiles.slice(0, 1)
|
||||
|
||||
onPaste(paste).then((result) => {
|
||||
if (!result) return
|
||||
})
|
||||
void onPaste(paste)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ export const useWorkflowPacks = (options: UseNodePacksOptions = {}) => {
|
||||
workflowPacks: nodePacks,
|
||||
startFetchWorkflowPacks: async () => {
|
||||
await getWorkflowPacks() // Parse the packs from the workflow nodes
|
||||
startFetch() // Fetch the packs infos from the registry
|
||||
await startFetch() // Fetch the packs infos from the registry
|
||||
},
|
||||
filterWorkflowPack
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export const useCanvasDrop = (canvasRef: Ref<HTMLCanvasElement>) => {
|
||||
usePragmaticDroppable(() => canvasRef.value, {
|
||||
getDropEffect: (args): Exclude<DataTransfer['dropEffect'], 'none'> =>
|
||||
args.source.data.type === 'tree-explorer-node' ? 'copy' : 'move',
|
||||
onDrop: (event) => {
|
||||
onDrop: async (event) => {
|
||||
const loc = event.location.current.input
|
||||
const dndData = event.source.data
|
||||
|
||||
@@ -79,7 +79,7 @@ export const useCanvasDrop = (canvasRef: Ref<HTMLCanvasElement>) => {
|
||||
loc.clientX,
|
||||
loc.clientY
|
||||
])
|
||||
workflowService.insertWorkflow(workflow, { position })
|
||||
await workflowService.insertWorkflow(workflow, { position })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,8 +107,8 @@ export function useCoreCommands(): ComfyCommand[] {
|
||||
icon: 'pi pi-download',
|
||||
label: 'Export Workflow',
|
||||
menubarLabel: 'Export',
|
||||
function: () => {
|
||||
workflowService.exportWorkflow('workflow', 'workflow')
|
||||
function: async () => {
|
||||
await workflowService.exportWorkflow('workflow', 'workflow')
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -116,8 +116,8 @@ export function useCoreCommands(): ComfyCommand[] {
|
||||
icon: 'pi pi-download',
|
||||
label: 'Export Workflow (API Format)',
|
||||
menubarLabel: 'Export (API)',
|
||||
function: () => {
|
||||
workflowService.exportWorkflow('workflow_api', 'output')
|
||||
function: async () => {
|
||||
await workflowService.exportWorkflow('workflow_api', 'output')
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -272,16 +272,19 @@ export function useCoreCommands(): ComfyCommand[] {
|
||||
const settingStore = useSettingStore()
|
||||
let lastLinksRenderMode = LiteGraph.SPLINE_LINK
|
||||
|
||||
return () => {
|
||||
return async () => {
|
||||
const currentMode = settingStore.get('Comfy.LinkRenderMode')
|
||||
|
||||
if (currentMode === LiteGraph.HIDDEN_LINK) {
|
||||
// If links are hidden, restore the last positive value or default to spline mode
|
||||
settingStore.set('Comfy.LinkRenderMode', lastLinksRenderMode)
|
||||
await settingStore.set('Comfy.LinkRenderMode', lastLinksRenderMode)
|
||||
} else {
|
||||
// If links are visible, store the current mode and hide links
|
||||
lastLinksRenderMode = currentMode
|
||||
settingStore.set('Comfy.LinkRenderMode', LiteGraph.HIDDEN_LINK)
|
||||
await settingStore.set(
|
||||
'Comfy.LinkRenderMode',
|
||||
LiteGraph.HIDDEN_LINK
|
||||
)
|
||||
}
|
||||
}
|
||||
})()
|
||||
@@ -291,9 +294,9 @@ export function useCoreCommands(): ComfyCommand[] {
|
||||
icon: 'pi pi-play',
|
||||
label: 'Queue Prompt',
|
||||
versionAdded: '1.3.7',
|
||||
function: () => {
|
||||
function: async () => {
|
||||
const batchCount = useQueueSettingsStore().batchCount
|
||||
app.queuePrompt(0, batchCount)
|
||||
await app.queuePrompt(0, batchCount)
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -301,9 +304,9 @@ export function useCoreCommands(): ComfyCommand[] {
|
||||
icon: 'pi pi-play',
|
||||
label: 'Queue Prompt (Front)',
|
||||
versionAdded: '1.3.7',
|
||||
function: () => {
|
||||
function: async () => {
|
||||
const batchCount = useQueueSettingsStore().batchCount
|
||||
app.queuePrompt(-1, batchCount)
|
||||
await app.queuePrompt(-1, batchCount)
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -345,8 +348,8 @@ export function useCoreCommands(): ComfyCommand[] {
|
||||
icon: 'pi pi-step-forward',
|
||||
label: 'Next Opened Workflow',
|
||||
versionAdded: '1.3.9',
|
||||
function: () => {
|
||||
workflowService.loadNextOpenedWorkflow()
|
||||
function: async () => {
|
||||
await workflowService.loadNextOpenedWorkflow()
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -354,8 +357,8 @@ export function useCoreCommands(): ComfyCommand[] {
|
||||
icon: 'pi pi-step-backward',
|
||||
label: 'Previous Opened Workflow',
|
||||
versionAdded: '1.3.9',
|
||||
function: () => {
|
||||
workflowService.loadPreviousOpenedWorkflow()
|
||||
function: async () => {
|
||||
await workflowService.loadPreviousOpenedWorkflow()
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -438,15 +441,15 @@ export function useCoreCommands(): ComfyCommand[] {
|
||||
let previousDarkTheme: string = DEFAULT_DARK_COLOR_PALETTE.id
|
||||
let previousLightTheme: string = DEFAULT_LIGHT_COLOR_PALETTE.id
|
||||
|
||||
return () => {
|
||||
return async () => {
|
||||
const settingStore = useSettingStore()
|
||||
const theme = colorPaletteStore.completedActivePalette
|
||||
if (theme.light_theme) {
|
||||
previousLightTheme = theme.id
|
||||
settingStore.set('Comfy.ColorPalette', previousDarkTheme)
|
||||
await settingStore.set('Comfy.ColorPalette', previousDarkTheme)
|
||||
} else {
|
||||
previousDarkTheme = theme.id
|
||||
settingStore.set('Comfy.ColorPalette', previousLightTheme)
|
||||
await settingStore.set('Comfy.ColorPalette', previousLightTheme)
|
||||
}
|
||||
}
|
||||
})()
|
||||
@@ -544,8 +547,8 @@ export function useCoreCommands(): ComfyCommand[] {
|
||||
icon: 'pi pi-clone',
|
||||
label: 'Duplicate Current Workflow',
|
||||
versionAdded: '1.6.15',
|
||||
function: () => {
|
||||
workflowService.duplicateWorkflow(workflowStore.activeWorkflow!)
|
||||
function: async () => {
|
||||
await workflowService.duplicateWorkflow(workflowStore.activeWorkflow!)
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -553,9 +556,9 @@ export function useCoreCommands(): ComfyCommand[] {
|
||||
icon: 'pi pi-times',
|
||||
label: 'Close Current Workflow',
|
||||
versionAdded: '1.7.3',
|
||||
function: () => {
|
||||
function: async () => {
|
||||
if (workflowStore.activeWorkflow)
|
||||
workflowService.closeWorkflow(workflowStore.activeWorkflow)
|
||||
await workflowService.closeWorkflow(workflowStore.activeWorkflow)
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -55,7 +55,8 @@ export function useDownload(url: string, fileName?: string) {
|
||||
// Try falling back to normal fetch if using Civitai API fails
|
||||
whenever(civitaiErr, fetchFileSize, { once: true })
|
||||
} else {
|
||||
fetchFileSize()
|
||||
// Fetch file size in the background
|
||||
void fetchFileSize()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ export const useRefreshableSelection = () => {
|
||||
if (!isRefreshable.value) return
|
||||
|
||||
if (isAllNodesSelected.value) {
|
||||
commandStore.execute('Comfy.RefreshNodeDefinitions')
|
||||
await commandStore.execute('Comfy.RefreshNodeDefinitions')
|
||||
} else {
|
||||
await Promise.all(refreshableWidgets.value.map((item) => item.refresh()))
|
||||
}
|
||||
|
||||
@@ -32,23 +32,23 @@ export const useServerLogs = (options: UseServerLogsOptions = {}) => {
|
||||
}
|
||||
}
|
||||
|
||||
const start = () => {
|
||||
api.subscribeLogs(true)
|
||||
const start = async () => {
|
||||
await api.subscribeLogs(true)
|
||||
stop = useEventListener(api, LOGS_MESSAGE_TYPE, handleLogMessage)
|
||||
}
|
||||
|
||||
const stopListening = () => {
|
||||
const stopListening = async () => {
|
||||
stop?.()
|
||||
stop = null
|
||||
api.subscribeLogs(false)
|
||||
await api.subscribeLogs(false)
|
||||
}
|
||||
|
||||
if (immediate) {
|
||||
start()
|
||||
void start()
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
stopListening()
|
||||
onUnmounted(async () => {
|
||||
await stopListening()
|
||||
logs.value = []
|
||||
})
|
||||
|
||||
|
||||
@@ -189,14 +189,18 @@ export function useRemoteWidget<
|
||||
* @returns the most recent value of the widget.
|
||||
*/
|
||||
function getValue(onFulfilled?: () => void) {
|
||||
fetchValue().then((data) => {
|
||||
if (isFirstLoad()) onFirstLoad(data)
|
||||
if (refreshQueued && data !== defaultValue) {
|
||||
onRefresh()
|
||||
refreshQueued = false
|
||||
}
|
||||
onFulfilled?.()
|
||||
})
|
||||
void fetchValue()
|
||||
.then((data) => {
|
||||
if (isFirstLoad()) onFirstLoad(data)
|
||||
if (refreshQueued && data !== defaultValue) {
|
||||
onRefresh()
|
||||
refreshQueued = false
|
||||
}
|
||||
onFulfilled?.()
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
})
|
||||
return getCachedValue() ?? defaultValue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user