From fc07c08c58d052b8617558c5c7abf6961ba643bc Mon Sep 17 00:00:00 2001 From: marcobaobao Date: Mon, 23 Dec 2024 09:35:22 +0100 Subject: [PATCH] fixed default template not selected --- frontend/src/components/ExtraDownloadOptions.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/ExtraDownloadOptions.tsx b/frontend/src/components/ExtraDownloadOptions.tsx index 83dda1f..2dc01da 100644 --- a/frontend/src/components/ExtraDownloadOptions.tsx +++ b/frontend/src/components/ExtraDownloadOptions.tsx @@ -1,13 +1,22 @@ import { Autocomplete, Box, TextField, Typography } from '@mui/material' +import { useAtomValue, useSetAtom } from 'jotai' +import { useEffect } from 'react' import { customArgsState, savedTemplatesState } from '../atoms/downloadTemplate' import { useI18n } from '../hooks/useI18n' -import { useAtom, useAtomValue } from 'jotai' const ExtraDownloadOptions: React.FC = () => { const { i18n } = useI18n() const customTemplates = useAtomValue(savedTemplatesState) - const [, setCustomArgs] = useAtom(customArgsState) + const setCustomArgs = useSetAtom(customArgsState) + + useEffect(() => { + setCustomArgs( + customTemplates + .find(f => f.name.toLocaleLowerCase() === 'default') + ?.content ?? '' + ) + }, []) return ( <>