Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
[C-1050] Fix profile search crash (#1916)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanjeffers committed Sep 13, 2022
1 parent 32b8c82 commit 7a167b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions packages/mobile/src/screens/profile-screen/ProfileScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import IconShare from 'app/assets/images/iconShare.svg'
import { IconButton, Screen } from 'app/components/core'
import { useNavigation } from 'app/hooks/useNavigation'
import { usePopToTopOnDrawerOpen } from 'app/hooks/usePopToTopOnDrawerOpen'
import { useRoute } from 'app/hooks/useRoute'
import { TopBarIconButton } from 'app/screens/app-screen'
import { makeStyles } from 'app/styles/makeStyles'
import { useThemeColors } from 'app/utils/theme'
Expand All @@ -29,7 +30,7 @@ import type { ProfileTabScreenParamList } from '../app-screen/ProfileTabScreen'

import { ProfileHeader } from './ProfileHeader'
import { ProfileTabNavigator } from './ProfileTabNavigator'
import { useSelectProfile } from './selectors'
import { useSelectProfileRoot } from './selectors'
const { requestOpen: requestOpenShareModal } = shareModalUIActions
const { fetchProfile: fetchProfileAction, resetProfile } = profilePageActions
const { getProfileStatus } = profilePageSelectors
Expand All @@ -56,19 +57,23 @@ const useStyles = makeStyles(({ spacing }) => ({
export const ProfileScreen = () => {
usePopToTopOnDrawerOpen()
const styles = useStyles()
const profile = useSelectProfile(['user_id', 'does_current_user_follow'])
const { handle, user_id } = profile
const { params } = useRoute<'Profile'>()
const profile = useSelectProfileRoot([
'user_id',
'handle',
'does_current_user_follow'
])
const handle = params.handle ?? profile?.handle
const accountId = useSelector(getUserId)
const dispatch = useDispatch()
const status = useSelector(getProfileStatus)
const [isRefreshing, setIsRefreshing] = useState(false)
const { neutralLight4, accentOrange } = useThemeColors()
const navigation = useNavigation<ProfileTabScreenParamList>()

const fetchProfile = useCallback(
() => dispatch(fetchProfileAction(handle, user_id, true, true, false)),
[dispatch, handle, user_id]
)
const fetchProfile = useCallback(() => {
dispatch(fetchProfileAction(handle, null, true, true, false))
}, [dispatch, handle])

const clearProfile = useCallback(() => {
dispatch(resetProfile())
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/src/screens/profile-screen/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const useSelectProfileRoot = (deps: Array<keyof User>) => {
isAccountUser ? getAccountUser(state) : getProfileUser(state, params),
(a, b) => deps.every((arg) => isEqual(a?.[arg], b?.[arg]))
)
return profile as User
return profile
}

/*
Expand Down

0 comments on commit 7a167b6

Please sign in to comment.