Skip to content

Commit

Permalink
fix: search translations in webhook tracked
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Jan 12, 2024
1 parent cd0c28b commit 5ef29ee
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/components/QueryData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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
Expand Down Expand Up @@ -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 &&
Expand Down
6 changes: 3 additions & 3 deletions src/components/layout/dialogs/filters/Advanced.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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 (
<Dialog
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/dialogs/filters/FilterMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DialogWrapper } from '../DialogWrapper'

export default function FilterMenu() {
const { open, category, type } = useLayoutStore((s) => s.dialog)
const filters = useStorage((s) => s.filters[category])
const filters = useStorage((s) => s.filters?.[category])

const [tempFilters, setTempFilters] = React.useState(filters?.filter)

Expand Down
4 changes: 2 additions & 2 deletions src/components/layout/dialogs/filters/SlotSelection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/dialogs/webhooks/Tracked.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const WebhookSearch = React.memo(() => {
setValue={(newValue) =>
useWebhookStore.setState({ trackedSearch: newValue })
}
label={`search_${category}`}
label={`search_${category}${category === 'pokemon' ? '' : 's'}`}
/>
)
})
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useLayoutStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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[],
* },
Expand Down Expand Up @@ -51,7 +51,7 @@ export const useLayoutStore = create(() => ({
slotSelection: '',
advancedFilter: {
open: false,
category: 'pokemon',
category: '',
id: '',
selectedIds: [],
},
Expand Down

0 comments on commit 5ef29ee

Please sign in to comment.