2023-05-18 13:17:41 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
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 ListItemIcon from '@mui/material/ListItemIcon';
|
|
|
|
|
import SearchIcon from '@mui/icons-material/Search';
|
2023-03-23 13:59:32 +01:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-06-05 01:42:39 +02:00
|
|
|
import { SearchMetadataKeys } from '@/typings';
|
|
|
|
|
import { requestUpdateServerMetadata } from '@/util/metadata';
|
|
|
|
|
import { useSearchSettings } from '@/util/searchSettings';
|
|
|
|
|
import makeToast from '@/components/util/Toast';
|
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>
|
|
|
|
|
);
|
|
|
|
|
}
|