Skip to content

Commit

Permalink
2101: Update header
Browse files Browse the repository at this point in the history
  • Loading branch information
LeandraH committed Nov 7, 2023
1 parent 873cf87 commit fb5da27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions native/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,12 @@ const Header = ({

const previousParams = previousRoute.params

// Poi details are not opened in a new route
if (route.name === POIS_ROUTE) {
if (
// Poi details are not opened in a new route
route.name === POIS_ROUTE &&
// unless coming from a deep link, and then the previous route has no slug
!!(previousParams as { slug?: string }).slug
) {
const poisRouteParams = route.params as RoutesParamsType[PoisRouteType]
if (poisRouteParams.slug || poisRouteParams.multipoi) {
return t('locations')
Expand Down
8 changes: 4 additions & 4 deletions native/src/routes/Pois.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const Pois = ({ pois: allPois, language, cityModel, route, navigation }: PoisPro
const { slug, multipoi } = route.params
const [sheetSnapPointIndex, setSheetSnapPointIndex] = useState<number>(1)
const [listScrollPosition, setListScrollPosition] = useState<number>(0)
const [enteredViaMaps, setEnteredViaMaps] = useState(slug === undefined)
const [deselectOnBackNavigation, setDeselectOnBackNavigation] = useState(slug === undefined)
const { t } = useTranslation('pois')
const scrollRef = useRef<BottomSheetScrollViewMethods>(null)
const deviceHeight = useWindowDimensions().height
Expand Down Expand Up @@ -135,15 +135,15 @@ const Pois = ({ pois: allPois, language, cityModel, route, navigation }: PoisPro
deselectAll()
}
}
useOnBackNavigation((slug || multipoi) && enteredViaMaps ? deselectFeature : undefined)
useOnBackNavigation((slug || multipoi) && deselectOnBackNavigation ? deselectFeature : undefined)

const selectFeatureOnMap = (feature: MapFeature | null) => {
if (!feature) {
deselectAll()
return
}

setEnteredViaMaps(true)
setDeselectOnBackNavigation(true)
if (isMultipoi(feature)) {
navigation.setParams({ multipoi: feature.id as string })
scrollTo(0)
Expand All @@ -159,7 +159,7 @@ const Pois = ({ pois: allPois, language, cityModel, route, navigation }: PoisPro
return
}

setEnteredViaMaps(true)
setDeselectOnBackNavigation(true)
navigation.setParams({ slug: newGeoJsonPoi.slug })
scrollTo(0)
}
Expand Down

0 comments on commit fb5da27

Please sign in to comment.