From f29d719df0cd5754576d63ea1253e106581eda2d Mon Sep 17 00:00:00 2001 From: marcobaobao Date: Thu, 12 Dec 2024 09:33:09 +0100 Subject: [PATCH] fixed never awaited cookies template promise --- frontend/src/atoms/downloadTemplate.ts | 4 ++-- frontend/src/components/DownloadDialog.tsx | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/atoms/downloadTemplate.ts b/frontend/src/atoms/downloadTemplate.ts index 3cf0276..74d74d0 100644 --- a/frontend/src/atoms/downloadTemplate.ts +++ b/frontend/src/atoms/downloadTemplate.ts @@ -22,8 +22,8 @@ export const filenameTemplateState = atomWithStorage( localStorage.getItem('lastFilenameTemplate') ?? '' ) -export const downloadTemplateState = atom((get) => - `${get(customArgsState)} ${get(cookiesTemplateState)}` +export const downloadTemplateState = atom>(async (get) => + `${get(customArgsState)} ${await get(cookiesTemplateState)}` .replace(/ +/g, ' ') .trim() ) diff --git a/frontend/src/components/DownloadDialog.tsx b/frontend/src/components/DownloadDialog.tsx index 953c2eb..bff0d8f 100644 --- a/frontend/src/components/DownloadDialog.tsx +++ b/frontend/src/components/DownloadDialog.tsx @@ -2,7 +2,6 @@ import { FileUpload } from '@mui/icons-material' import CloseIcon from '@mui/icons-material/Close' import { Autocomplete, - Backdrop, Box, Button, Checkbox, @@ -21,6 +20,7 @@ import Slide from '@mui/material/Slide' import Toolbar from '@mui/material/Toolbar' import Typography from '@mui/material/Typography' import { TransitionProps } from '@mui/material/transitions' +import { useAtom, useAtomValue } from 'jotai' import { FC, Suspense, @@ -30,18 +30,22 @@ import { useState, useTransition } from 'react' -import { customArgsState, downloadTemplateState, filenameTemplateState, savedTemplatesState } from '../atoms/downloadTemplate' +import { + customArgsState, + downloadTemplateState, + filenameTemplateState, + savedTemplatesState +} from '../atoms/downloadTemplate' import { settingsState } from '../atoms/settings' import { availableDownloadPathsState, connectedState } from '../atoms/status' import FormatsGrid from '../components/FormatsGrid' +import { useToast } from '../hooks/toast' import { useI18n } from '../hooks/useI18n' import { useRPC } from '../hooks/useRPC' import type { DLMetadata } from '../types' import { toFormatArgs } from '../utils' import ExtraDownloadOptions from './ExtraDownloadOptions' -import { useToast } from '../hooks/toast' import LoadingBackdrop from './LoadingBackdrop' -import { useAtom, useAtomValue } from 'jotai' const Transition = forwardRef(function Transition( props: TransitionProps & {