diff --git a/src/components/pages/serverSettings/parts/ServerSettingsFiles.tsx b/src/components/pages/serverSettings/parts/ServerSettingsFiles.tsx index 90004016a..52b4b2c22 100644 --- a/src/components/pages/serverSettings/parts/ServerSettingsFiles.tsx +++ b/src/components/pages/serverSettings/parts/ServerSettingsFiles.tsx @@ -55,15 +55,23 @@ export default function ServerSettingsFiles({ values.filesDefaultExpiration = values.filesDefaultExpiration.trim(); } - if (values.filesDisabledExtensions?.trim() === '' || !values.filesDisabledExtensions) { + if (!values.filesDisabledExtensions) { // @ts-ignore values.filesDisabledExtensions = []; - } else { + } else if ( + values.filesDisabledExtensions && + typeof values.filesDisabledExtensions === 'string' && + values.filesDisabledExtensions.trim() === '' + ) { // @ts-ignore - values.filesDisabledExtensions = values.filesDisabledExtensions - .split(',') - .map((ext) => ext.trim()) - .filter((ext) => ext !== ''); + values.filesDisabledExtensions = []; + } else { + if (!Array.isArray(values.filesDisabledExtensions)) + // @ts-ignore + values.filesDisabledExtensions = values.filesDisabledExtensions + .split(',') + .map((ext) => ext.trim()) + .filter((ext) => ext !== ''); } return settingsOnSubmit(router, form)(values); diff --git a/src/components/pages/upload/UploadOptionsButton.tsx b/src/components/pages/upload/UploadOptionsButton.tsx index c2d9e196f..2178d1a18 100755 --- a/src/components/pages/upload/UploadOptionsButton.tsx +++ b/src/components/pages/upload/UploadOptionsButton.tsx @@ -1,3 +1,4 @@ +import { useConfig } from '@/components/ConfigProvider'; import { Response } from '@/lib/api/response'; import { Folder } from '@/lib/db/models/folder'; import { useUploadOptionsStore } from '@/lib/store/uploadOptions'; @@ -30,10 +31,14 @@ import { IconTrashFilled, IconWriting, } from '@tabler/icons-react'; +import Link from 'next/link'; import { useState } from 'react'; import useSWR from 'swr'; +import ms from 'ms'; export default function UploadOptionsButton({ numFiles }: { numFiles: number }) { + const config = useConfig(); + const [opened, setOpen] = useState(false); const [options, ephemeral, setOption, setEphemeral, changes] = useUploadOptionsStore((state) => [ state.options, @@ -113,7 +118,23 @@ export default function UploadOptionsButton({ numFiles }: { numFiles: number }) ) : null} } - description='The file will automatically delete itself after this time.' + description={ + <> + The file will automatically delete itself after this time.{' '} + {config.files.defaultExpiration ? ( + <> + The default expiration time is {ms(config.files.defaultExpiration)} (you can + override this with the below option). + + ) : ( + <> + {'You can set a default expiration time in the '} + settings + {'.'} + + )} + + } leftSection={} value={options.deletesAt} onChange={(value) => setOption('deletesAt', value || 'never')} @@ -129,7 +150,7 @@ export default function UploadOptionsButton({ numFiles }: { numFiles: number })