Skip to content

Commit

Permalink
feat: skip places when user has just one
Browse files Browse the repository at this point in the history
  • Loading branch information
czabaj committed Sep 2, 2024
1 parent 66e86e9 commit 6b5af8a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/pages/Homepage/Homepage.res
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ let make = () => {
<a
className={Styles.button.sizeLarge}
href="/misto"
onClick={RouterUtils.handleLinkClick((. ()) => {
let navigate = () => RescriptReactRouter.push("/misto")
onClick={RouterUtils.handleLinkClick(() => {
let navigate = () => RescriptReactRouter.push(`/misto#${RouterUtils.fromHomepageHash}`)
if !supportsTransitionApi {
navigate()
} else {
Expand Down
9 changes: 7 additions & 2 deletions src/pages/MyPlaces/MyPlaces.res
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,14 @@ let make = () => {
)
let (dialogState, setDialogState) = React.useState(() => Hidden)
let hideDialog = _ => setDialogState(_ => Hidden)
let fromHomepage = RescriptReactRouter.useUrl()->RouterUtils.isFromHomepage
<>
{switch pageDataStatus.data {
| Some((currentUser, usersPlaces)) =>
{switch (fromHomepage, pageDataStatus.data) {
| (true, Some(_, [onePlaceOnly])) =>
let singlePlaceLocation = RouterUtils.resolveRelativePath(`./${Db.getUid(onePlaceOnly)}`)
RescriptReactRouter.replace(singlePlaceLocation)
React.null
| (_, Some(currentUser, usersPlaces)) =>
let userDisplayName = currentUser.displayName->Null.getExn
<>
<Pure
Expand Down
4 changes: 4 additions & 0 deletions src/utils/RouterUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@ let createShareLink = shareLinkId => {
let origin = Dom.location->Dom.Location.origin
`${origin}/s/${shareLinkId}`
}

let fromHomepageHash = "from_homepage"

let isFromHomepage = (url: RescriptReactRouter.url) => url.hash == fromHomepageHash

0 comments on commit 6b5af8a

Please sign in to comment.