Page MenuHomePhabricator

D9120.diff
No OneTemporary

D9120.diff

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 @@
<View style={styles.container}>
<SWMansionIcon name="menu-vertical" size={24} style={styles.moreIcon} />
<View style={styles.userInfoContainer}>
- <UserAvatar size="profile" userID={userInfo.id} />
+ <UserAvatar size="profile" userID={userInfo?.id} />
<View style={styles.usernameContainer}>
<SingleLine style={styles.usernameText}>{usernameText}</SingleLine>
{copyUsernameButton}

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 10:27 PM (18 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2565953
Default Alt Text
D9120.diff (2 KB)

Event Timeline