Skip to content

Commit

Permalink
fix header issue for user page
Browse files Browse the repository at this point in the history
  • Loading branch information
denniske committed Nov 1, 2024
1 parent dc0fb43 commit f6430d4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
28 changes: 20 additions & 8 deletions app/src/app/matches/users/[profileId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Icon } from '@app/components/icon';
import { toggleFollowing } from '@app/service/following';
import Search from '@app/view/components/search';
import { MainPageInner } from '@app/view/main.page';
import { Stack, router, useLocalSearchParams, useNavigation } from 'expo-router';
import { router, useLocalSearchParams, useNavigation } from 'expo-router';
import React, { useEffect, useState } from 'react';
import { ActivityIndicator, Alert, Platform, TouchableOpacity } from 'react-native';

Expand All @@ -18,9 +18,13 @@ import { getVerifiedPlayer, isVerifiedPlayer } from '@nex/data';
import { Text } from '@app/components/text';
import { Link } from '@app/components/link';

export function UserMenu() {
const { profileId: profileIdParam } = useLocalSearchParams<{ profileId: string }>();
const profileId = Number(profileIdParam ?? 0);
interface UserMenuProps {
profileId: number;
}

// Due to some bug in expo-router we cannot use useLocalSearchParams
// so we need to pass the profileId as a prop
export function UserMenu({ profileId }: UserMenuProps) {
const auth = useSelector((state) => state.auth!);
const account = useSelector((state) => state.account);
const profile = useSelector((state) => state.user[profileId]?.profile);
Expand Down Expand Up @@ -85,17 +89,25 @@ export function UserMenu() {
}
}

type UserPageParams = {
profileId: string;
name?: string;
country?: string
}

export default function UserPage() {
const { profileId: profileIdParam, name, country } = useLocalSearchParams<{ profileId: string; name?: string; country?: string }>();
const profileId = Number(profileIdParam ?? 0);
const params = useLocalSearchParams<UserPageParams>();
const profileId = Number(params.profileId ?? 0);
const name = params.name;
const country = params.country;

const mutate = useMutate();
const [loadedProfile, setLoadedProfile] = useState<IProfilesResultProfile>();
const auth = useSelector((state) => state.auth);
const account = useSelector((state) => state.account);
const isVerified = isVerifiedPlayer(profileId);
const verified = getVerifiedPlayer(profileId);
const isMainAccount = verified?.platforms.rl?.[0] === profileIdParam;
const isMainAccount = verified?.platforms.rl?.[0] === params.profileId;

const onSelect = async (user: any) => {
await saveSettingsToStorage({
Expand Down Expand Up @@ -160,7 +172,7 @@ export default function UserPage() {
}
/>
),
headerRight: () => <UserMenu />,
headerRight: () => <UserMenu profileId={profileId} />,
});
}, [navigation, loadedProfile, isVerified, isMainAccount, country, name]);

Expand Down
4 changes: 4 additions & 0 deletions app/src/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ export const changelog: IChangelog = {
title: 'Steam Family Sharing Indicator',
content: 'Show family icon next to player in match popup and on profile',
},
{
type: 'bugfix',
title: 'Fix header on profile page showing wrong icons',
},
],
'116.0.0': [
{
Expand Down

0 comments on commit f6430d4

Please sign in to comment.