Skip to content

Commit

Permalink
fix: remove excludeList - no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Jan 18, 2024
1 parent d51408d commit bc3adba
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 202 deletions.
3 changes: 0 additions & 3 deletions src/components/QueryData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ function QueryData({ category, timeout }) {
if (active) {
timeout.current.setupTimeout(refetch)
return () => {
useMemory.setState((prev) => ({
excludeList: prev.excludeList.length ? [] : prev.excludeList,
}))
timeout.current.off()
}
}
Expand Down
19 changes: 2 additions & 17 deletions src/components/popups/Gym.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useTranslation } from 'react-i18next'
import { useSyncData } from '@components/layout/dialogs/webhooks/hooks'
import { useMemory } from '@hooks/useMemory'
import { useLayoutStore } from '@hooks/useLayoutStore'
import { useStorage } from '@hooks/useStorage'
import { setDeepStore, useStorage } from '@hooks/useStorage'
import useWebhook from '@hooks/useWebhook'
import Utility from '@services/Utility'
import ErrorBoundary from '@components/ErrorBoundary'
Expand Down Expand Up @@ -193,22 +193,7 @@ const DropdownOptions = ({

const handleExclude = (key) => {
handleClose()
useStorage.setState((prev) => ({
filters: {
...prev.filters,
gyms: {
...prev.filters.gyms,
filter: {
...prev.filters.gyms.filter,
[key]: {
...prev.filters.gyms.filter[key],
enabled: false,
},
},
},
},
}))
useMemory.setState((prev) => ({ excludeList: [...prev.excludeList, key] }))
setDeepStore(`filters.gyms.filter.${key}.enabled`, false)
}

const excludeTeam = () => handleExclude(`t${team_id}-0`)
Expand Down
19 changes: 2 additions & 17 deletions src/components/popups/Nest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useTranslation } from 'react-i18next'

import { useMemory } from '@hooks/useMemory'
import { useLayoutStore } from '@hooks/useLayoutStore'
import { useStorage } from '@hooks/useStorage'
import { setDeepStore } from '@hooks/useStorage'
import Utility from '@services/Utility'
import ErrorBoundary from '@components/ErrorBoundary'
import NestSubmission from '@components/layout/dialogs/NestSubmission'
Expand Down Expand Up @@ -74,22 +74,7 @@ export default function NestPopup({
const handleExclude = () => {
setAnchorEl(null)
const key = `${pokemon_id}-${pokemon_form}`
useStorage.setState((prev) => ({
filters: {
...prev.filters,
nests: {
...prev.filters.nests,
filter: {
...prev.filters.nests.filter,
[key]: {
...prev.filters.nests.filter[key],
enabled: false,
},
},
},
},
}))
useMemory.setState((prev) => ({ excludeList: [...prev.excludeList, key] }))
setDeepStore(`filters.nests.filter.${key}.enabled`, false)
}

const options = [
Expand Down
23 changes: 3 additions & 20 deletions src/components/popups/Pokemon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { useTranslation } from 'react-i18next'

import { useMemory } from '@hooks/useMemory'
import { useStorage } from '@hooks/useStorage'
import { setDeepStore, useStorage } from '@hooks/useStorage'
import Utility from '@services/Utility'
import ErrorBoundary from '@components/ErrorBoundary'
import { TextWithIcon } from '@components/layout/general/Img'
Expand Down Expand Up @@ -187,26 +187,9 @@ const Header = ({

const handleExclude = () => {
setAnchorEl(null)
const key = `${pokemon_id}-${form}`
if (filters?.pokemon?.filter) {
useStorage.setState((prev) => ({
filters: {
...prev.filters,
pokemon: {
...prev.filters.pokemon,
filter: {
...prev.filters.pokemon.filter,
[key]: {
...prev.filters.pokemon.filter[key],
enabled: false,
},
},
},
},
}))
useMemory.setState((prev) => ({
excludeList: [...prev.excludeList, key],
}))
const key = `${pokemon_id}-${form}`
setDeepStore(`filters.pokemon.filter.${key}.enabled`, false)
}
}

Expand Down
22 changes: 3 additions & 19 deletions src/components/popups/Pokestop.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useTranslation, Trans } from 'react-i18next'
import ErrorBoundary from '@components/ErrorBoundary'
import { Check, Help } from '@components/layout/general/Icons'
import { useMemory } from '@hooks/useMemory'
import { useStorage } from '@hooks/useStorage'
import { setDeepStore, useStorage } from '@hooks/useStorage'
import Utility from '@services/Utility'
import { getBadge } from '@services/functions/getBadge'
import getRewardInfo from '@services/functions/getRewardInfo'
Expand Down Expand Up @@ -328,24 +328,8 @@ const MenuActions = ({
useMemory.setState((prev) => ({ hideList: new Set(prev.hideList).add(id) }))
}

const setState = (key) => {
useStorage.setState((prev) => ({
filters: {
...prev.filters,
pokestops: {
...prev.filters.pokestops,
filter: {
...prev.filters.pokestops.filter,
[key]: {
...prev.filters.pokestops.filter[key],
enabled: false,
},
},
},
},
}))
useMemory.setState((prev) => ({ excludeList: [...prev.excludeList, key] }))
}
const setState = (key) =>
setDeepStore(`filters.pokestops.filter.${key}.enabled`, false)

const excludeLure = () => {
setAnchorEl(null)
Expand Down
116 changes: 54 additions & 62 deletions src/components/tiles/Gym.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const GymTile = (gym) => {
const [
hasRaid,
hasHatched,
excludeTeam,
inTimerList,
interactionRangeZoom,
gymIconUrl,
Expand All @@ -52,7 +51,7 @@ const GymTile = (gym) => {
audio,
] = useMemory((s) => {
const newTs = Date.now() / 1000
const { excludeList, timerList, config, Icons, Audio } = s
const { timerList, config, Icons, Audio } = s
const { filters, userSettings } = useStorage.getState()

const filledSlots =
Expand All @@ -65,18 +64,13 @@ const GymTile = (gym) => {
const eggFilterId = `e${gym.raid_level}`

const hasRaidInternal =
gym.raid_end_timestamp >= newTs &&
gym.raid_level > 0 &&
(gym.raid_battle_timestamp >= newTs
? !excludeList.includes(eggFilterId)
: !excludeList.includes(raidFilterId))
gym.raid_end_timestamp >= newTs && gym.raid_level > 0
const hasHatchedInternal =
gym.raid_end_timestamp >= newTs && gym.raid_battle_timestamp <= newTs

return [
hasRaidInternal,
hasHatchedInternal,
excludeList.includes(`t${gym.team_id}-0`),
timerList.includes(gym.id),
config.general.interactionRangeZoom,
Icons.getGyms(
Expand Down Expand Up @@ -172,60 +166,58 @@ const GymTile = (gym) => {
})
}
return (
!excludeTeam && (
<Marker
ref={setMarkerRef}
position={[gym.lat, gym.lon]}
icon={gymMarker({
showDiamond,
showExBadge,
showArBadge,
showRaidLevel,
opacity,
gymIconUrl,
gymIconSize,
raidIconUrl,
raidIconSize,
...gym,
})}
>
<Popup position={[gym.lat, gym.lon]}>
<PopupContent
hasRaid={hasRaid}
hasHatched={hasHatched}
raidIconUrl={raidIconUrl}
{...gym}
/>
</Popup>
{showTimer && (
<ToolTipWrapper timers={[timerToDisplay]} offset={[0, 5]} />
)}
{showInteractionRange && (
<Circle
center={[gym.lat, gym.lon]}
radius={80}
color={getColor(gym.team_id)}
weight={0.5}
/>
)}
{show300mCircles && (
<Circle
center={[gym.lat, gym.lon]}
radius={300}
color={getColor(gym.team_id)}
weight={0.5}
/>
)}
{!!customRange && (
<Circle
center={[gym.lat, gym.lon]}
radius={customRange}
color={getColor(gym.team_id)}
weight={0.5}
/>
)}
</Marker>
)
<Marker
ref={setMarkerRef}
position={[gym.lat, gym.lon]}
icon={gymMarker({
showDiamond,
showExBadge,
showArBadge,
showRaidLevel,
opacity,
gymIconUrl,
gymIconSize,
raidIconUrl,
raidIconSize,
...gym,
})}
>
<Popup position={[gym.lat, gym.lon]}>
<PopupContent
hasRaid={hasRaid}
hasHatched={hasHatched}
raidIconUrl={raidIconUrl}
{...gym}
/>
</Popup>
{showTimer && (
<ToolTipWrapper timers={[timerToDisplay]} offset={[0, 5]} />
)}
{showInteractionRange && (
<Circle
center={[gym.lat, gym.lon]}
radius={80}
color={getColor(gym.team_id)}
weight={0.5}
/>
)}
{show300mCircles && (
<Circle
center={[gym.lat, gym.lon]}
radius={300}
color={getColor(gym.team_id)}
weight={0.5}
/>
)}
{!!customRange && (
<Circle
center={[gym.lat, gym.lon]}
radius={customRange}
color={getColor(gym.team_id)}
weight={0.5}
/>
)}
</Marker>
)
}

Expand Down
8 changes: 2 additions & 6 deletions src/components/tiles/Nest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ const NestTile = (nest) => {
const size = useStorage(
(s) => s.filters.nests.filter[internalId]?.size || 'md',
)
const [excluded, iconUrl, iconSize] = useMemory((s) => {
const { Icons, excludeList } = s
const [iconUrl, iconSize] = useMemory((s) => {
const { Icons } = s
return [
excludeList.includes(internalId),
Icons.getPokemon(nest.pokemon_id, nest.pokemon_form),
Icons.getSize('nest', size),
]
Expand All @@ -42,9 +41,6 @@ const NestTile = (nest) => {
}),
[iconUrl, iconSize, nest.pokemon_id, recent],
)
if (excluded) {
return null
}

return (
<>
Expand Down
Loading

0 comments on commit bc3adba

Please sign in to comment.