diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 5d3a21a6..6154d651 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -160,6 +160,7 @@ "audioDeviceFetchError": "an error occurred when trying to get audio devices", "authenticationFailed": "authentication failed", "badAlbum": "you are seeing this page because this song is not part of an album. you are most likely seeing this issue if you have a song at the top level of your music folder. jellyfin only groups tracks if they are in a folder.", + "badValue": "invalid option \"{{value}}\". this value no longer exists", "credentialsRequired": "credentials required", "endpointNotImplementedError": "endpoint {{endpoint}} is not implemented for {{serverType}}", "genericError": "an error occurred", diff --git a/src/renderer/components/select-with-invalid-data/index.tsx b/src/renderer/components/select-with-invalid-data/index.tsx new file mode 100644 index 00000000..46053094 --- /dev/null +++ b/src/renderer/components/select-with-invalid-data/index.tsx @@ -0,0 +1,78 @@ +import { MultiSelect, MultiSelectProps, Select, SelectProps } from '/@/renderer/components/select'; +import { useTranslation } from 'react-i18next'; +import { useMemo } from 'react'; + +export const SelectWithInvalidData = ({ data, defaultValue, ...props }: SelectProps) => { + const { t } = useTranslation(); + + const [fullData, hasError] = useMemo(() => { + if (typeof defaultValue === 'string') { + const missingField = + data.find((item) => + typeof item === 'string' ? item === defaultValue : item.value === defaultValue, + ) === undefined; + + if (missingField) { + return [data.concat(defaultValue), true]; + } + } + + return [data, false]; + }, [data, defaultValue]); + + return ( + - ; @@ -201,7 +202,7 @@ export const JellyfinSongFilters = ({ {!isGenrePage && ( - - ; @@ -149,7 +150,7 @@ export const NavidromeSongFilters = ({ onChange={(e) => handleYearFilter(e)} /> {!isGenrePage && ( -