From 4ed1fdbe2f0cf6754680922cfd6c4ca63bb9dab1 Mon Sep 17 00:00:00 2001 From: Dennis Keil Date: Fri, 18 Aug 2023 16:57:43 +0200 Subject: [PATCH] fix following --- app/src/api/following.ts | 4 ++-- app/src/service/following.ts | 3 ++- app/src/service/storage.ts | 2 +- app/src/view/components/game-overlay.tsx | 2 +- app/src/view/user.page.tsx | 10 +++------- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/app/src/api/following.ts b/app/src/api/following.ts index 9e8bb6abd..5f16b90a8 100644 --- a/app/src/api/following.ts +++ b/app/src/api/following.ts @@ -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; } diff --git a/app/src/service/following.ts b/app/src/service/following.ts index f968cbde6..ce2b23eca 100644 --- a/app/src/service/following.ts +++ b/app/src/service/following.ts @@ -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 { @@ -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, diff --git a/app/src/service/storage.ts b/app/src/service/storage.ts index 1ecd11f3b..1dd20d9ef 100644 --- a/app/src/service/storage.ts +++ b/app/src/service/storage.ts @@ -46,8 +46,8 @@ export interface IAccount { } export interface IFollowingEntry { - profileId: number; steam_id?: string; + profileId: number; profile_id?: number; name: string; games: number; diff --git a/app/src/view/components/game-overlay.tsx b/app/src/view/components/game-overlay.tsx index 870d6a8a0..b8d380501 100644 --- a/app/src/view/components/game-overlay.tsx +++ b/app/src/view/components/game-overlay.tsx @@ -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) => { - sortBy(players, p => p.color).map((player, j) => sameUser(hu, player))} match={match} player={player} freeForALl={freeForALl} canDownloadRec={canDownloadRec(player)}/>) + sortBy(players, p => p.color).map((player, j) => hu.profileId === player.profile_id)} match={match} player={player} freeForALl={freeForALl} canDownloadRec={canDownloadRec(player)}/>) } { i < teams.length-1 && diff --git a/app/src/view/user.page.tsx b/app/src/view/user.page.tsx index f2aff4a8c..0203a4cc0 100644 --- a/app/src/view/user.page.tsx +++ b/app/src/view/user.page.tsx @@ -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 ( @@ -93,10 +93,6 @@ export function UserMenu() { ); } -function isValidUserInfo(userInfo: any) { - return userInfo && (userInfo.steamId || userInfo.profileId); -} - export default function UserPage() { const route = useRoute>(); const profileId = route.params?.profileId; @@ -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(); generateTestHook('Navigation')(navigation); @@ -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