Fix profile load issue + enhancement of profile isCurrent style (#764)

* fix profile isActive issue

* fix myProfile load issue when visiting other profiles first

* fix lint issues

* change currentRouteName to currentRouteInfo
zio/stable
MohammadReza Mahmoudi 2023-05-31 03:12:22 +03:30 committed by GitHub
parent 5d0a3e6c65
commit 442d453600
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

@ -47,6 +47,10 @@ export const ProfileScreen = withAuthRequired(
)
useSetTitle(combinedDisplayName(uiState.profile))
useEffect(() => {
setHasSetup(false)
}, [route.params.name])
useFocusEffect(
React.useCallback(() => {
let aborted = false

View File

@ -91,14 +91,17 @@ const NavItem = observer(
const pal = usePalette('default')
const store = useStores()
const [pathName] = React.useMemo(() => router.matchPath(href), [href])
const currentRouteName = useNavigationState(state => {
const currentRouteInfo = useNavigationState(state => {
if (!state) {
return 'Home'
return {name: 'Home'}
}
return getCurrentRoute(state).name
return getCurrentRoute(state)
})
const isCurrent = isTab(currentRouteName, pathName)
let isCurrent =
currentRouteInfo.name === 'Profile'
? isTab(currentRouteInfo.name, pathName) &&
currentRouteInfo.params.name === store.me.handle
: isTab(currentRouteInfo.name, pathName)
const {onPress} = useLinkProps({to: href})
const onPressWrapped = React.useCallback(
(e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {