Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Profile link from drawer on Mobile Web #1437

Merged
merged 6 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ const MyProfileTabNavigator = observer(function MyProfileTabNavigatorImpl() {
component={ProfileScreen}
initialParams={{
name: store.me.did,
hideBackButton: true,
}}
/>
{commonScreens(MyProfileTab as typeof HomeTab)}
Expand All @@ -362,7 +361,9 @@ const MyProfileTabNavigator = observer(function MyProfileTabNavigatorImpl() {
*/
const FlatNavigator = observer(function FlatNavigatorImpl() {
const pal = usePalette('default')
const unreadCountLabel = useStores().me.notifications.unreadCountLabel
const store = useStores()
const unreadCountLabel = store.me.notifications.unreadCountLabel

const title = (page: string) => bskyTitle(page, unreadCountLabel)
return (
<Flat.Navigator
Expand Down
4 changes: 4 additions & 0 deletions src/view/shell/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export const DrawerContent = observer(function DrawerContentImpl() {
const state = navigation.getState()
store.shell.closeDrawer()
if (isWeb) {
// hack because we have flat navigator for web and MyProfile does not exist on the web navigator -ansh
if (tab === 'MyProfile') {
navigation.navigate('Profile', {name: store.me.handle})
}
ansh marked this conversation as resolved.
Show resolved Hide resolved
// @ts-ignore must be Home, Search, Notifications, or MyProfile
navigation.navigate(tab)
} else {
Expand Down
28 changes: 20 additions & 8 deletions src/view/shell/bottom-bar/BottomBarWeb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import {
SatelliteDishIcon,
SatelliteDishIconSolid,
UserIcon,
UserIconSolid,
} from 'lib/icons'
import {Link} from 'view/com/util/Link'
import {useMinimalShellMode} from 'lib/hooks/useMinimalShellMode'
import {makeProfileLink} from 'lib/routes/links'
import {CommonNavigatorParams} from 'lib/routes/types'

export const BottomBarWeb = observer(function BottomBarWebImpl() {
const store = useStores()
Expand Down Expand Up @@ -89,13 +91,16 @@ export const BottomBarWeb = observer(function BottomBarWebImpl() {
}}
</NavItem>
<NavItem routeName="Profile" href={makeProfileLink(store.me)}>
{() => (
<UserIcon
size={28}
strokeWidth={1.5}
style={[styles.ctrlIcon, pal.text, styles.profileIcon]}
/>
)}
{({isActive}) => {
const Icon = isActive ? UserIconSolid : UserIcon
return (
<Icon
size={28}
strokeWidth={1.5}
style={[styles.ctrlIcon, pal.text, styles.profileIcon]}
/>
)
}}
</NavItem>
</Animated.View>
)
Expand All @@ -107,7 +112,14 @@ const NavItem: React.FC<{
routeName: string
}> = ({children, href, routeName}) => {
const currentRoute = useNavigationState(getCurrentRoute)
const isActive = isTab(currentRoute.name, routeName)
const store = useStores()
const isActive =
currentRoute.name === 'Profile'
? isTab(currentRoute.name, routeName) &&
(currentRoute.params as CommonNavigatorParams['Profile']).name ===
store.me.handle
: isTab(currentRoute.name, routeName)

return (
<Link href={href} style={styles.ctrl}>
{children({isActive})}
Expand Down