Skip to content

Commit

Permalink
Fix new post button on web after following intent URL (#3044)
Browse files Browse the repository at this point in the history
* Fix new post button on web after following intent URL

* Ensure that `routes` exists before attempting to use it
  • Loading branch information
haileyok authored Mar 2, 2024
1 parent 8bf40b4 commit e950463
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,19 @@ const LINKING = {
},

getStateFromPath(path: string) {
const [name, params] = router.matchPath(path)

// Any time we receive a url that starts with `intent/` we want to ignore it here. It will be handled in the
// intent handler hook. We should check for the trailing slash, because if there isn't one then it isn't a valid
// intent
if (path.includes('intent/')) return
// On web, there is no route state that's created by default, so we should initialize it as the home route. On
// native, since the home tab and the home screen are defined as initial routes, we don't need to return a state
// since it will be created by react-navigation.
if (path.includes('intent/')) {
if (isNative) return
return buildStateObject('Flat', 'Home', params)
}

const [name, params] = router.matchPath(path)
if (isNative) {
if (name === 'Search') {
return buildStateObject('SearchTab', 'Search', params)
Expand Down
6 changes: 3 additions & 3 deletions src/view/shell/desktop/LeftNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ function ComposeBtn() {
const fetchHandle = useFetchHandle()

const getProfileHandle = async () => {
const {routes} = getState()
const currentRoute = routes[routes.length - 1]
const routes = getState()?.routes
const currentRoute = routes?.[routes?.length - 1]

if (currentRoute.name === 'Profile') {
if (currentRoute?.name === 'Profile') {
let handle: string | undefined = (
currentRoute.params as CommonNavigatorParams['Profile']
).name
Expand Down

0 comments on commit e950463

Please sign in to comment.