fix(ui): prompt parsing in useImageActions

This commit is contained in:
psychedelicious
2025-07-04 19:58:33 +10:00
parent 767ac91f2c
commit 0d3af08d27

View File

@@ -40,18 +40,23 @@ export const useImageActions = (imageDTO: ImageDTO | null) => {
setHasSeed(false);
}
let hasPrompt = false;
// Need to catch all of these to avoid unhandled promise rejections bubbling up to instrumented error handlers
const promptParseResults = await Promise.allSettled([
MetadataHandlers.PositivePrompt.parse(metadata, store).catch(() => {}),
MetadataHandlers.NegativePrompt.parse(metadata, store).catch(() => {}),
MetadataHandlers.PositiveStylePrompt.parse(metadata, store).catch(() => {}),
MetadataHandlers.NegativeStylePrompt.parse(metadata, store).catch(() => {}),
]);
if (promptParseResults.some((result) => result.status === 'fulfilled')) {
setHasPrompts(true);
} else {
setHasPrompts(false);
for (const handler of [
MetadataHandlers.PositivePrompt,
MetadataHandlers.NegativePrompt,
MetadataHandlers.PositiveStylePrompt,
MetadataHandlers.NegativeStylePrompt,
]) {
try {
await handler.parse(metadata, store);
hasPrompt = true;
break;
} catch {
// noop
}
}
setHasPrompts(hasPrompt);
} else {
setHasMetadata(false);
setHasSeed(false);