Fix setting "default" download conversion mime type

The server expects the mime type to be "default", while the ui set it to "image/default"
This commit is contained in:
schroda
2025-09-13 14:13:32 +02:00
parent 792aca1b28
commit 38ac36d14c

View File

@@ -55,12 +55,20 @@ const normalizeConversions = (conversions: SettingsDownloadConversion[]): Settin
target: normalizeMimeType(conversion.target), target: normalizeMimeType(conversion.target),
})); }));
const toValidServerMimeType = (mimeType: string): string => {
if (isDefaultMimeType(mimeType)) {
return DEFAULT_MIME_TYPE;
}
return `${MIME_TYPE_PREFIX}${mimeType}`;
};
const toValidServerConversions = (conversions: SettingsDownloadConversion[]): SettingsDownloadConversion[] => const toValidServerConversions = (conversions: SettingsDownloadConversion[]): SettingsDownloadConversion[] =>
conversions conversions
.filter(({ mimeType, target }) => !!mimeType && !!target) .filter(({ mimeType, target }) => !!mimeType && !!target)
.map((conversion) => ({ .map((conversion) => ({
...conversion, ...conversion,
mimeType: `${MIME_TYPE_PREFIX}${conversion.mimeType}`, mimeType: toValidServerMimeType(conversion.mimeType),
target: `${MIME_TYPE_PREFIX}${conversion.target}`, target: `${MIME_TYPE_PREFIX}${conversion.target}`,
})); }));
@@ -265,6 +273,15 @@ export const DownloadConversionSetting = ({
onClose(conversions); onClose(conversions);
}; };
const onSubmit = async () => {
try {
await updateSetting(toValidServerConversions(tmpConversions));
onClose(toValidServerConversions(tmpConversions));
} catch (e) {
// ignore error
}
};
return ( return (
<> <>
<ListItemButton disabled={false} onClick={() => setIsDialogOpen(true)}> <ListItemButton disabled={false} onClick={() => setIsDialogOpen(true)}>
@@ -332,14 +349,7 @@ export const DownloadConversionSetting = ({
</Button> </Button>
<Stack direction="row"> <Stack direction="row">
<Button onClick={onCancel}>{t('global.button.cancel')}</Button> <Button onClick={onCancel}>{t('global.button.cancel')}</Button>
<Button <Button disabled={hasInvalidConversion || !hasChanged} onClick={onSubmit}>
disabled={hasInvalidConversion || !hasChanged}
onClick={() =>
updateSetting(toValidServerConversions(tmpConversions)).then(() =>
onClose(toValidServerConversions(tmpConversions)),
)
}
>
{t('global.button.ok')} {t('global.button.ok')}
</Button> </Button>
</Stack> </Stack>