mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix(image): image-to-pdf presets no longer 404 on 2+ files (#633)
jpg-to-pdf and its six image-to-pdf-group siblings share the base tool's registerImageToPdfRoute, which never registers into the toolRegistry the generic /batch endpoint reads from. The shared conversion-preset settings component routed any 2+-file submission to /batch regardless of tool, so these presets 404'd with `Tool "<id>" not found` past the first file, while the base image-to-pdf tool stayed unaffected because it bypasses that dispatch entirely with its own settings component. MULTI_FILE_TOOLS now includes every image-to-pdf-group preset, derived from BASE_CONFIG instead of hardcoded, and the preset settings component checks that set before choosing batch vs. a single combined request. Fixes #627
This commit is contained in:
@@ -6,6 +6,7 @@ import { ProgressCard } from "@/components/common/progress-card";
|
||||
import { useTranslation } from "@/contexts/i18n-context";
|
||||
import { useToolProcessor } from "@/hooks/use-tool-processor";
|
||||
import { format } from "@/lib/format";
|
||||
import { MULTI_FILE_TOOLS } from "@/lib/tool-display-modes";
|
||||
import { useFileStore } from "@/stores/file-store";
|
||||
|
||||
/** Target formats that honor a quality knob (lossy raster encodings). */
|
||||
@@ -46,8 +47,14 @@ export function ConversionPresetSettings() {
|
||||
|
||||
const handleProcess = () => {
|
||||
const settings = buildSettings();
|
||||
if (files.length > 1) processAllFiles(files, settings);
|
||||
else processFiles(files, settings);
|
||||
// image-to-pdf-group presets combine every file into one request (same as
|
||||
// the base tool), so they must skip the generic per-file /batch endpoint
|
||||
// that MULTI_FILE_TOOLS-gated tools never register into (issue #627).
|
||||
if (MULTI_FILE_TOOLS.has(toolId) || files.length <= 1) {
|
||||
processFiles(files, settings);
|
||||
} else {
|
||||
processAllFiles(files, settings);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
|
||||
@@ -227,9 +227,15 @@ for (const preset of CONVERSION_PRESETS) {
|
||||
|
||||
/**
|
||||
* Tools whose selected files all post in ONE request as repeated "file" parts.
|
||||
* Consumed by use-tool-processor; backend routes declare maxInputs.
|
||||
* Consumed by use-tool-processor and ConversionPresetSettings; backend routes
|
||||
* declare maxInputs, or (image-to-pdf group) loop over every uploaded file
|
||||
* with no cap. Conversion presets built on a combining base are added below
|
||||
* from BASE_CONFIG so a future image-to-pdf-group preset can't drift out of
|
||||
* sync the way jpg-to-pdf did (issue #627): registerImageToPdfRoute never
|
||||
* registers into the createToolRoute/registerToolProcessFn registry that the
|
||||
* generic per-file /batch route depends on, so those tools 404 there.
|
||||
*/
|
||||
export const MULTI_FILE_TOOLS: ReadonlySet<string> = new Set([
|
||||
const multiFileTools = new Set<string>([
|
||||
"create-zip",
|
||||
"merge-audio",
|
||||
"merge-csvs",
|
||||
@@ -241,3 +247,9 @@ export const MULTI_FILE_TOOLS: ReadonlySet<string> = new Set([
|
||||
"images-to-video",
|
||||
"sprite-sheet",
|
||||
]);
|
||||
for (const preset of CONVERSION_PRESETS) {
|
||||
if (BASE_CONFIG[preset.base].group === "image-to-pdf") {
|
||||
multiFileTools.add(preset.id);
|
||||
}
|
||||
}
|
||||
export const MULTI_FILE_TOOLS: ReadonlySet<string> = multiFileTools;
|
||||
|
||||
Reference in New Issue
Block a user