Skip to content

Commit cfbfd09

Browse files
committed
feat: hidden persistence
1 parent 11c75e0 commit cfbfd09

File tree

11 files changed

+194
-13
lines changed

11 files changed

+194
-13
lines changed

packages/locales/lib/human/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@
138138
"exclude_lure": "Exclude Lure",
139139
"timer": "Timer",
140140
"hide": "Hide",
141+
"hidden_for_hour": "Hidden for an hour",
142+
"clean_hidden": "Clean Hidden",
141143
"tier": "Tier",
142144
"slots": "Slots",
143145
"mega": "Mega",

packages/locales/lib/human/pl.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@
228228
"has_quest_indicator": "Alternatywny kolor dla Pokéstopów z zadaniami",
229229
"help": "Pomoc",
230230
"hide": "Ukryj",
231+
"hidden_for_hour": "Schowano na godzinę",
232+
"clean_hidden": "Wyczyść schowane",
231233
"hide_editor": "Ukryj edytor",
232234
"historic_rarity": "Rzadkość historyczna",
233235
"hisuian": "Hisuian",

src/features/drawer/settings/index.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import InsightsIcon from '@mui/icons-material/Insights'
99
import NotificationsActiveIcon from '@mui/icons-material/NotificationsActive'
1010
import NotificationsOffIcon from '@mui/icons-material/NotificationsOff'
1111
import LogoDevIcon from '@mui/icons-material/LogoDev'
12+
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff'
1213
import { useTranslation } from 'react-i18next'
1314

1415
import { useMemory } from '@store/useMemory'
@@ -22,6 +23,7 @@ import { LocaleSelection } from '@components/inputs/LocaleSelection'
2223
import { DividerWithMargin } from '@components/StyledDivider'
2324
import { BoolToggle } from '@components/inputs/BoolToggle'
2425
import { BasicListButton } from '@components/inputs/BasicListButton'
26+
import { clearHiddenEntities } from '@utils/pokemon/hiddenPokemon'
2527

2628
import { DrawerActions } from '../components/Actions'
2729
import { GeneralSetting } from './General'
@@ -70,6 +72,15 @@ export function Settings() {
7072
</BasicListButton>
7173
)}
7274
<HolidaySetting />
75+
<BasicListButton
76+
onClick={() => {
77+
clearHiddenEntities()
78+
useMemory.setState({ hideList: new Set() })
79+
}}
80+
label="clean_hidden"
81+
>
82+
<VisibilityOffIcon />
83+
</BasicListButton>
7384
<DividerWithMargin />
7485
<UAssetSetting asset="icons" />
7586
<UAssetSetting asset="audio" />

src/features/gym/GymPopup.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { getTimeUntil } from '@utils/getTimeUntil'
3737
import { formatInterval } from '@utils/formatInterval'
3838
import { usePokemonBackgroundVisuals } from '@hooks/usePokemonBackgroundVisuals'
3939
import { getFormDisplay } from '@utils/getFormDisplay'
40+
import { addHiddenEntity, showHideSnackbar } from '@utils/pokemon/hiddenPokemon'
4041

4142
import { useWebhook } from './useWebhook'
4243

@@ -747,7 +748,8 @@ const DropdownOptions = ({
747748

748749
const handleHide = () => {
749750
handleClose()
750-
useMemory.setState((prev) => ({ hideList: new Set(prev.hideList).add(id) }))
751+
useMemory.setState({ hideList: addHiddenEntity(id) })
752+
showHideSnackbar(t('hidden_for_hour'))
751753
}
752754

753755
const handleExclude = (key) => {

src/features/nest/NestPopup.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { setDeepStore } from '@store/useStorage'
1616
import { getTimeUntil } from '@utils/getTimeUntil'
1717
import { useAnalytics } from '@hooks/useAnalytics'
1818
import { Navigation } from '@components/popups/Navigation'
19+
import { addHiddenEntity, showHideSnackbar } from '@utils/pokemon/hiddenPokemon'
1920

2021
/** @param {number} timeSince */
2122
const getColor = (timeSince) => {
@@ -62,7 +63,8 @@ export function NestPopup({
6263
const handleClose = () => setAnchorEl(null)
6364
const handleHide = () => {
6465
setAnchorEl(null)
65-
useMemory.setState((prev) => ({ hideList: new Set(prev.hideList).add(id) }))
66+
useMemory.setState({ hideList: addHiddenEntity(id) })
67+
showHideSnackbar(t('hidden_for_hour'))
6668
}
6769

6870
const handleExclude = () => {

src/features/pokemon/PokemonPopup.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { GET_TAPPABLE_BY_ID } from '@services/queries/tappable'
3333
import { usePokemonBackgroundVisual } from '@hooks/usePokemonBackgroundVisuals'
3434
import { BackgroundCard } from '@components/popups/BackgroundCard'
3535
import { getFormDisplay } from '@utils/getFormDisplay'
36+
import { addHiddenEntity } from '@utils/pokemon/hiddenPokemon'
3637

3738
const rowClass = { width: 30, fontWeight: 'bold' }
3839

@@ -357,7 +358,7 @@ const Header = ({ pokemon, metaData, iconUrl, userSettings, isTutorial }) => {
357358

358359
const handleHide = () => {
359360
setAnchorEl(null)
360-
useMemory.setState((prev) => ({ hideList: new Set(prev.hideList).add(id) }))
361+
useMemory.setState({ hideList: addHiddenEntity(id) })
361362
}
362363

363364
const handleExclude = () => {

src/features/pokestop/PokestopPopup.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { useGetAvailable } from '@hooks/useGetAvailable'
3535
import { parseQuestConditions } from '@utils/parseConditions'
3636
import { Img } from '@components/Img'
3737
import { readableProbability } from '@utils/readableProbability'
38+
import { addHiddenEntity, showHideSnackbar } from '@utils/pokemon/hiddenPokemon'
3839
import {
3940
usePokemonBackgroundVisuals,
4041
usePokemonBackgroundVisual,
@@ -341,7 +342,8 @@ const MenuActions = ({
341342

342343
const handleHide = () => {
343344
setAnchorEl(null)
344-
useMemory.setState((prev) => ({ hideList: new Set(prev.hideList).add(id) }))
345+
useMemory.setState({ hideList: addHiddenEntity(id) })
346+
showHideSnackbar(t('hidden_for_hour'))
345347
}
346348

347349
/** @param {string} key */

src/features/station/StationPopup.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { Img, PokemonImg } from '@components/Img'
2727
import { useFormatStore } from '@store/useFormatStore'
2828
import { useRelativeTimer } from '@hooks/useRelativeTime'
2929
import { useAnalytics } from '@hooks/useAnalytics'
30+
import { addHiddenEntity, showHideSnackbar } from '@utils/pokemon/hiddenPokemon'
3031
import { BackgroundCard } from '@components/popups/BackgroundCard'
3132
import { Title } from '@components/popups/Title'
3233
import {
@@ -169,10 +170,10 @@ function StationMenu({
169170
() => [
170171
{
171172
name: 'hide',
172-
action: () =>
173-
useMemory.setState((prev) => ({
174-
hideList: new Set(prev.hideList).add(id),
175-
})),
173+
action: () => {
174+
useMemory.setState({ hideList: addHiddenEntity(id) })
175+
showHideSnackbar(t('hidden_for_hour'))
176+
},
176177
},
177178
{
178179
name: 'exclude_battle',

src/features/tappable/TappablePopup.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { StatusIcon } from '@components/StatusIcon'
2020
import { Title } from '@components/popups/Title'
2121

2222
import { getTimeUntil } from '@utils/getTimeUntil'
23+
import { addHiddenEntity, showHideSnackbar } from '@utils/pokemon/hiddenPokemon'
24+
2325
import { getTappableDisplaySettings } from './displayRules'
2426

2527
/**
@@ -107,10 +109,9 @@ export function TappablePopup({ tappable, rewardIcon }) {
107109
const handleHide = React.useCallback(() => {
108110
setMenuAnchorEl(null)
109111
if (tappable.id === undefined || tappable.id === null) return
110-
useMemory.setState((prev) => ({
111-
hideList: new Set(prev.hideList).add(tappable.id),
112-
}))
113-
}, [tappable.id])
112+
useMemory.setState({ hideList: addHiddenEntity(tappable.id) })
113+
showHideSnackbar(t('hidden_for_hour'))
114+
}, [tappable.id, t])
114115

115116
const handleExclude = React.useCallback(() => {
116117
setMenuAnchorEl(null)

src/store/useMemory.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import { create } from 'zustand'
44

5+
import { getHiddenEntitySet } from '@utils/pokemon/hiddenPokemon'
6+
57
/**
68
* TODO: Finish this
79
* @typedef {{
@@ -151,7 +153,7 @@ export const useMemory = create(() => ({
151153
locationCards: {},
152154
routeTypes: {},
153155
},
154-
hideList: new Set(),
156+
hideList: getHiddenEntitySet(),
155157
timerList: [],
156158
timeOfDay: 'day',
157159
extraUserFields: [],

0 commit comments

Comments
 (0)