2023-03-04 22:21:24 +05:30
|
|
|
import { ListItem, ListItemText, Switch } from '@mui/material';
|
|
|
|
|
import ListItemSecondaryAction from '@mui/material/ListItemSecondaryAction';
|
|
|
|
|
import React from 'react';
|
|
|
|
|
import { useSearchSettings } from 'util/searchSettings';
|
|
|
|
|
import { requestUpdateServerMetadata } from 'util/metadata';
|
|
|
|
|
import makeToast from 'components/util/Toast';
|
|
|
|
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
|
|
|
import SearchIcon from '@mui/icons-material/Search';
|
|
|
|
|
import { SearchMetadataKeys } from 'typings';
|
2023-03-23 13:59:32 +01:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-03-04 22:21:24 +05:30
|
|
|
|
|
|
|
|
export default function SearchSettings() {
|
2023-03-23 13:59:32 +01:00
|
|
|
const { t } = useTranslation();
|
2023-03-04 22:21:24 +05:30
|
|
|
const { metadata, settings } = useSearchSettings();
|
|
|
|
|
|
|
|
|
|
const setSettingValue = (key: SearchMetadataKeys, value: boolean) => {
|
|
|
|
|
requestUpdateServerMetadata(metadata ?? {}, [[key, value]]).catch(() =>
|
2023-03-23 13:59:32 +01:00
|
|
|
makeToast(t('search.error.label.failed_to_save_settings'), 'warning'),
|
2023-03-04 22:21:24 +05:30
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<ListItem>
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<SearchIcon />
|
|
|
|
|
</ListItemIcon>
|
2023-03-23 13:59:32 +01:00
|
|
|
<ListItemText primary={t('search.label.ignore_filters')} />
|
2023-03-04 22:21:24 +05:30
|
|
|
<ListItemSecondaryAction>
|
|
|
|
|
<Switch
|
|
|
|
|
edge="end"
|
|
|
|
|
checked={settings.ignoreFilters}
|
|
|
|
|
onChange={(e) => setSettingValue('ignoreFilters', e.target.checked)}
|
|
|
|
|
/>
|
|
|
|
|
</ListItemSecondaryAction>
|
|
|
|
|
</ListItem>
|
|
|
|
|
);
|
|
|
|
|
}
|