From 846c13070673bca2f0e14751aa8fdb7322fb8ed9 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Thu, 2 Nov 2023 19:54:43 -0700 Subject: [PATCH] Lookup did for my profile at screen to avoid bad actor error (#1800) --- src/Navigation.tsx | 3 +-- src/view/screens/Profile.tsx | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Navigation.tsx b/src/Navigation.tsx index 49a2c429..a6949de2 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -349,7 +349,6 @@ function NotificationsTabNavigator() { const MyProfileTabNavigator = observer(function MyProfileTabNavigatorImpl() { const contentStyle = useColorSchemeStyle(styles.bgLight, styles.bgDark) - const store = useStores() return ( ProfileScreen} initialParams={{ - name: store.me.did, + name: 'me', }} /> {commonScreens(MyProfileTab as typeof HomeTab)} diff --git a/src/view/screens/Profile.tsx b/src/view/screens/Profile.tsx index c1ab6931..6c5a84e8 100644 --- a/src/view/screens/Profile.tsx +++ b/src/view/screens/Profile.tsx @@ -36,6 +36,7 @@ export const ProfileScreen = withAuthRequired( const store = useStores() const {screen, track} = useAnalytics() const viewSelectorRef = React.useRef(null) + const name = route.params.name === 'me' ? store.me.did : route.params.name useEffect(() => { screen('Profile') @@ -43,8 +44,8 @@ export const ProfileScreen = withAuthRequired( const [hasSetup, setHasSetup] = useState(false) const uiState = React.useMemo( - () => new ProfileUiModel(store, {user: route.params.name}), - [route.params.name, store], + () => new ProfileUiModel(store, {user: name}), + [name, store], ) useSetTitle(combinedDisplayName(uiState.profile)) @@ -54,7 +55,7 @@ export const ProfileScreen = withAuthRequired( useEffect(() => { setHasSetup(false) - }, [route.params.name]) + }, [name]) // We don't need this to be reactive, so we can just register the listeners once useEffect(() => {