Skip to content

Commit

Permalink
Reset override mapwhen going back
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciabad committed Feb 22, 2024
1 parent 46236dd commit 1e567ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/app/[locale]/(app)/explore/_components/override-main-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type OverrideMainMapProps = {
emphasizedMarkers?: SetOfMarkers
veryEmphasizedMarkers?: SetOfMarkers
veryEmphasizedLines?: SetOfLines
reset?: boolean
}

export const OverrideMainMap: FC<OverrideMainMapProps> = memo(
Expand All @@ -23,6 +24,7 @@ export const OverrideMainMap: FC<OverrideMainMapProps> = memo(
emphasizedMarkers,
veryEmphasizedMarkers,
veryEmphasizedLines,
reset,
}) => {
const {
map,
Expand All @@ -44,10 +46,14 @@ export const OverrideMainMap: FC<OverrideMainMapProps> = memo(
}
}

setEmphasizedMarkers(emphasizedMarkers)
if (reset) {
setEmphasizedMarkers(new Set())
setVeryEmphasizedMarkers(new Set())
setVeryEmphasizedLines(new Set())
}

setEmphasizedMarkers(emphasizedMarkers)
setVeryEmphasizedMarkers(veryEmphasizedMarkers)

setVeryEmphasizedLines(veryEmphasizedLines)
}
}, [map])
Expand Down
3 changes: 3 additions & 0 deletions src/app/[locale]/(app)/explore/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { onlyTranslatableLocales, type LocaleRouteParams } from '~/i18n'
import { getTrpc } from '~/server/get-server-thing'
import { CategoriesGrid } from './_components/categories-grid'
import { ListPlacesOfCategory } from './_components/list-places-of-category'
import { OverrideMainMap } from './_components/override-main-map'

export async function generateMetadata({
params: { locale },
Expand Down Expand Up @@ -38,6 +39,8 @@ const ExplorePage: FC<LocaleRouteParams> = async () => {

return (
<>
<OverrideMainMap reset />

<CategoriesGrid categories={categories} />

<div className="space-y-2">
Expand Down

0 comments on commit 1e567ac

Please sign in to comment.