Skip to content

Commit

Permalink
fix: try/catch on expert filter just in case
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Feb 21, 2024
1 parent 53e0495 commit 4e430e6
Showing 1 changed file with 35 additions and 21 deletions.
56 changes: 35 additions & 21 deletions src/components/layout/dialogs/filters/StringFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,42 @@ export function StringFilter({ field, ...props }) {
/** @type {import('@mui/material').TextFieldProps['onChange']} */ (
React.useCallback(
(event) => {
const newValue = event.target.value
Utility.analytics('Filtering', newValue, 'Legacy')
if (Utility.checkAdvFilter(newValue)) {
setValidation({
label: t('valid'),
status: false,
message: t('valid_filter'),
})
} else if (newValue === '') {
setValidation({
label: t('iv_or_filter'),
status: false,
message: t('overwrites'),
})
} else {
setValidation({
label: t('invalid'),
status: true,
message: t('invalid_filter'),
})
try {
const newValue = event.target.value
Utility.analytics('Filtering', newValue, 'Legacy')
if (Utility.checkAdvFilter(newValue)) {
setValidation({
label: t('valid'),
status: false,
message: t('valid_filter'),
})
} else if (newValue === '') {
setValidation({
label: t('iv_or_filter'),
status: false,
message: t('overwrites'),
})
} else {
setValidation({
label: t('invalid'),
status: true,
message: t('invalid_filter'),
})
}
useStorage.setState((prev) =>
setDeep(prev, `${field}.adv`, newValue),
)
} catch (err) {
// eslint-disable-next-line no-console
console.error(err)
if (err instanceof Error) {
setValidation({
label: t('invalid'),
status: true,
message: err.message,
})
}
}
useStorage.setState((prev) => setDeep(prev, `${field}.adv`, newValue))
},
[field],
)
Expand Down

0 comments on commit 4e430e6

Please sign in to comment.