diff --git a/lib/shared/user-utils.js b/lib/shared/user-utils.js --- a/lib/shared/user-utils.js +++ b/lib/shared/user-utils.js @@ -10,24 +10,26 @@ import type { UserInfo } from '../types/user-types.js'; import { useSelector } from '../utils/redux-utils.js'; -function stringForUser(user: { - +username?: ?string, - +isViewer?: ?boolean, - ... -}): string { - if (user.isViewer) { +function stringForUser( + user: ?{ + +username?: ?string, + +isViewer?: ?boolean, + ... + }, +): string { + if (user?.isViewer) { return 'you'; } return stringForUserExplicit(user); } -function stringForUserExplicit(user: { +username: ?string, ... }): string { - if (user.username) { +function stringForUserExplicit(user: ?{ +username: ?string, ... }): string { + if (user?.username) { return user.username; - } else { - return 'anonymous'; } + + return 'anonymous'; } function useKeyserverAdmin( diff --git a/native/bottom-sheets/user-profile-bottom-sheet.react.js b/native/bottom-sheets/user-profile-bottom-sheet.react.js --- a/native/bottom-sheets/user-profile-bottom-sheet.react.js +++ b/native/bottom-sheets/user-profile-bottom-sheet.react.js @@ -2,15 +2,16 @@ import * as React from 'react'; -import type { AccountUserInfo } from 'lib/types/user-types.js'; +import type { UserInfo } from 'lib/types/user-types'; import BottomSheet from './bottom-sheet.react.js'; import UserProfile from '../components/user-profile.react.js'; import type { RootNavigationProp } from '../navigation/root-navigator.react.js'; import type { NavigationRoute } from '../navigation/route-names.js'; +import { useSelector } from '../redux/redux-utils.js'; export type UserProfileBottomSheetParams = { - +userInfo: AccountUserInfo, + +userID: string, }; type Props = { @@ -22,12 +23,16 @@ const { navigation, route: { - params: { userInfo }, + params: { userID }, }, } = props; const { goBackOnce } = navigation; + const userInfo: ?UserInfo = useSelector( + state => state.userStore.userInfos[userID], + ); + const bottomSheetRef = React.useRef(); React.useEffect(() => { diff --git a/native/components/user-profile.react.js b/native/components/user-profile.react.js --- a/native/components/user-profile.react.js +++ b/native/components/user-profile.react.js @@ -14,7 +14,7 @@ import { useStyles } from '../themes/colors.js'; type Props = { - +userInfo: UserInfo, + +userInfo: ?UserInfo, }; function UserProfile(props: Props): React.Node { @@ -68,7 +68,7 @@ - + {usernameText} {copyUsernameButton}