Skip to content

Commit

Permalink
fix following
Browse files Browse the repository at this point in the history
  • Loading branch information
denniske committed Aug 18, 2023
1 parent 649dede commit 4ed1fdb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/src/api/following.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ export async function sendTestPushNotificationElectron(push_token_electron: stri
}

export interface IAccountProfile {
profileId?: number | null;
steamId?: string | null;
profile_id?: number | null;
steam_id?: string | null;
overlay?: boolean;
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/service/following.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const toggleFollowing = async (user: IPlayerListPlayer) => {
const account_id = store.getState().account!.id;

const following = await loadFollowingFromStorage();
const index = following.findIndex(f => sameUser(f, user));
const index = following.findIndex(f => f.profileId, user.profileId);
if (index > -1) {
await unfollow(account_id, [user.profileId]);
} else {
Expand All @@ -30,6 +30,7 @@ export const toggleFollowing = async (user: IPlayerListPlayer) => {
} else {
following2.push({
steam_id: user.steamId,
profileId: user.profileId,
profile_id: user.profileId,
name: user.name,
games: user.games,
Expand Down
2 changes: 1 addition & 1 deletion app/src/service/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export interface IAccount {
}

export interface IFollowingEntry {
profileId: number;
steam_id?: string;
profileId: number;
profile_id?: number;
name: string;
games: number;
Expand Down
2 changes: 1 addition & 1 deletion app/src/view/components/game-overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export function GameOverlay({match, user, highlightedUsers, expanded = false}: I
sortBy(teams, ([team, players], i) => min(players.map(p => p.color))).map(([team, players], i) =>
<View key={team}>
{
sortBy(players, p => p.color).map((player, j) => <Player key={j} highlight={highlightedUsers?.some(hu => sameUser(hu, player))} match={match} player={player} freeForALl={freeForALl} canDownloadRec={canDownloadRec(player)}/>)
sortBy(players, p => p.color).map((player, j) => <Player key={j} highlight={highlightedUsers?.some(hu => hu.profileId === player.profile_id)} match={match} player={player} freeForALl={freeForALl} canDownloadRec={canDownloadRec(player)}/>)
}
{
i < teams.length-1 &&
Expand Down
10 changes: 3 additions & 7 deletions app/src/view/user.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function UserMenu() {
index: 0,
routes: [{name: 'User'}],
});
setAccountProfile(account.id, { profileId: null, steamId: null });
setAccountProfile(account.id, { profile_id: null, steam_id: null });
};

return (
Expand All @@ -93,10 +93,6 @@ export function UserMenu() {
);
}

function isValidUserInfo(userInfo: any) {
return userInfo && (userInfo.steamId || userInfo.profileId);
}

export default function UserPage() {
const route = useRoute<RouteProp<RootStackParamList, 'User'>>();
const profileId = route.params?.profileId;
Expand All @@ -106,13 +102,13 @@ export default function UserPage() {
const auth = useSelector(state => state.auth);
const account = useSelector(state => state.account);
const profile = useSelector(state => state.user[profileId]?.profile);
const [hasSteamId, setHasSteamId] = useState(true);

console.log('==> UserPage');
console.log(route.params);
console.log(auth);
console.log(profileId);


const generateTestHook = useCavy();
const navigation = useNavigation<RootStackProp>();
generateTestHook('Navigation')(navigation);
Expand All @@ -122,7 +118,7 @@ export default function UserPage() {
profileId: user.profileId,
});
mutate(setAuth(user));
setAccountProfile(account.id, { profileId: user.profileId!, steamId: user.steamId });
setAccountProfile(account.id, { profile_id: user.profileId!, steam_id: user.steamId });
};

// Reset country for use in leaderboard country dropdown
Expand Down

0 comments on commit 4ed1fdb

Please sign in to comment.