From 5ef29ee53855fc0065b465dc53915ea21efb91ab Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Fri, 12 Jan 2024 12:46:38 -0500 Subject: [PATCH] fix: search translations in webhook tracked --- src/components/QueryData.jsx | 6 +++--- src/components/layout/dialogs/filters/Advanced.jsx | 6 +++--- src/components/layout/dialogs/filters/FilterMenu.jsx | 2 +- src/components/layout/dialogs/filters/SlotSelection.jsx | 4 ++-- src/components/layout/dialogs/webhooks/Tracked.jsx | 2 +- src/hooks/useLayoutStore.js | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/QueryData.jsx b/src/components/QueryData.jsx index e1dd1ec2c..7cede24f1 100644 --- a/src/components/QueryData.jsx +++ b/src/components/QueryData.jsx @@ -49,7 +49,7 @@ const trimFilters = (requestedFilters, userSettings, category, onlyAreas) => { onlyAllPvp: userSettings?.showAllPvpRanks, onlyAreas: onlyAreas || [], } - Object.entries(requestedFilters).forEach((topLevelFilter) => { + Object.entries(requestedFilters || {}).forEach((topLevelFilter) => { const [id, specifics] = topLevelFilter if (!FILTER_SKIP_LIST.includes(id)) { @@ -62,7 +62,7 @@ const trimFilters = (requestedFilters, userSettings, category, onlyAreas) => { entryV } }) - Object.entries(requestedFilters.filter).forEach(([id, specifics]) => { + Object.entries(requestedFilters?.filter || {}).forEach(([id, specifics]) => { // eslint-disable-next-line no-unused-vars const { enabled, size, ...rest } = (easyMode ? requestedFilters.ivOr @@ -107,7 +107,7 @@ function QueryData({ category, timeout }) { const userSettings = useStorage( (s) => s.userSettings[userSettingsCategory(category)], ) - const filters = useStorage((s) => s.filters[category]) + const filters = useStorage((s) => s.filters?.[category]) const onlyAreas = useStorage( (s) => s.filters?.scanAreas?.filterByAreas && diff --git a/src/components/layout/dialogs/filters/Advanced.jsx b/src/components/layout/dialogs/filters/Advanced.jsx index 5947d2557..2329469ba 100644 --- a/src/components/layout/dialogs/filters/Advanced.jsx +++ b/src/components/layout/dialogs/filters/Advanced.jsx @@ -43,7 +43,7 @@ export default function AdvancedFilter() { ) const easyMode = useStorage((s) => !!s.filters?.[category]?.easyMode) const [filters, setFilters] = useDeepStore( - `filters.${category}.filter.${id}`, + category ? `filters.${category}.filter.${id}` : `filters.gyms.standard`, standard, ) const backup = React.useRef(filters) @@ -77,7 +77,7 @@ export default function AdvancedFilter() { })) if (!save) { setFilters({ ...backup.current }) - } else if (id === 'global' && selectedIds?.length) { + } else if (id === 'global' && selectedIds?.length && category) { applyToAll(true, category, selectedIds, false) } } @@ -113,7 +113,7 @@ export default function AdvancedFilter() { if (open) backup.current = filters }, [open]) - if (!id) return null + if (!id || !category) return null const showMoreFilters = category === 'pokemon' && !easyMode return ( s.dialog) - const filters = useStorage((s) => s.filters[category]) + const filters = useStorage((s) => s.filters?.[category]) const [tempFilters, setTempFilters] = React.useState(filters?.filter) diff --git a/src/components/layout/dialogs/filters/SlotSelection.jsx b/src/components/layout/dialogs/filters/SlotSelection.jsx index 99e65f061..5efa9fab8 100644 --- a/src/components/layout/dialogs/filters/SlotSelection.jsx +++ b/src/components/layout/dialogs/filters/SlotSelection.jsx @@ -26,12 +26,12 @@ export default function SlotSelection() { }, basicEqualFn) const slots = useMemory( (s) => - Object.keys(s.filters.gyms.filter).filter( + Object.keys(s.filters?.gyms?.filter || {}).filter( (g) => g.startsWith('g') && g.charAt(1) === teamId, ), basicEqualFn, ) - const disabled = useStorage((s) => s.filters.gyms.filter[id]?.all) + const disabled = useStorage((s) => !!s.filters?.gyms?.filter?.[id]?.all) /** @type {(value: boolean | import('packages/types/lib').BaseFilter['size'], team: string) => void} */ const handleSizeChange = React.useCallback( diff --git a/src/components/layout/dialogs/webhooks/Tracked.jsx b/src/components/layout/dialogs/webhooks/Tracked.jsx index 9c0f77abe..fc97bffb7 100644 --- a/src/components/layout/dialogs/webhooks/Tracked.jsx +++ b/src/components/layout/dialogs/webhooks/Tracked.jsx @@ -58,7 +58,7 @@ export const WebhookSearch = React.memo(() => { setValue={(newValue) => useWebhookStore.setState({ trackedSearch: newValue }) } - label={`search_${category}`} + label={`search_${category}${category === 'pokemon' ? '' : 's'}`} /> ) }) diff --git a/src/hooks/useLayoutStore.js b/src/hooks/useLayoutStore.js index 702bc0c3d..77bb1c9e8 100644 --- a/src/hooks/useLayoutStore.js +++ b/src/hooks/useLayoutStore.js @@ -19,7 +19,7 @@ import { useStorage } from './useStorage' * drawer: boolean, * advancedFilter: { * open: boolean, - * category: import('@rm/types').AdvCategories, + * category: import('@rm/types').AdvCategories | '', * id: string, * selectedIds: string[], * }, @@ -51,7 +51,7 @@ export const useLayoutStore = create(() => ({ slotSelection: '', advancedFilter: { open: false, - category: 'pokemon', + category: '', id: '', selectedIds: [], },