diff --git a/front/volume/src/App.svelte b/front/volume/src/App.svelte index 960a2c4..6290326 100644 --- a/front/volume/src/App.svelte +++ b/front/volume/src/App.svelte @@ -25,12 +25,9 @@ import Leaderboard from "./components/Leaderboard.svelte"; import Pong from "./components/Pong/Pong.svelte"; - import type { Player } from "./components/Profile.svelte"; - import type { Match } from "./components/MatchHistory.svelte"; - import type { Friend } from "./components/Friends.svelte"; import type { ChannelsType } from "./components/Channels.svelte"; - import { store, getUser, login, verify, API_URL } from "./Auth"; + import { store, getUser, login, verify } from "./Auth"; import FakeLogin from "./FakeLogin.svelte"; // Single Page Application config @@ -53,7 +50,6 @@ history.pushState({ appState }, "", appState); } - // PROFILE onMount(() => { getUser(); }); @@ -62,21 +58,15 @@ }, 15000); function clickProfile() { - userProfile = $store; setAppState(APPSTATE.PROFILE); } - let userProfile: Player; + let profileUsername: string; async function openIdProfile(event: CustomEvent) { - console.log("Opening profile: " + event.detail); - const res = await fetch(API_URL + "/user/" + event.detail, { - mode: "cors", - }); - userProfile = await res.json(); + profileUsername = event.detail; setAppState(APPSTATE.PROFILE_ID); } - // HISTORY async function clickHistory() { setAppState(APPSTATE.HISTORY); } @@ -85,37 +75,14 @@ setAppState(APPSTATE.HISTORY_ID); } - // FRIENDS - let friends: Friend[] = []; - let invits: Friend[] = []; - let friendsInterval: ReturnType; - - async function getFriends(): Promise { - let response = await fetch(API_URL + "/friends", { - credentials: "include", - mode: "cors", - }); - return await response.json(); - } - async function getInvits(): Promise { - let response = await fetch(API_URL + "/invits", { - credentials: "include", - mode: "cors", - }); - return await response.json(); - } - async function clickFriends() { setAppState(APPSTATE.FRIENDS); - friends = await getFriends(); - invits = await getInvits(); - friendsInterval = setInterval(async () => { - friends = await getFriends(); - invits = await getInvits(); - }, 5000); } - // CHANNELS + async function clickLeaderboard() { + setAppState(APPSTATE.LEADERBOARD); + } + function clickChannels() { setAppState(APPSTATE.CHANNELS); } @@ -136,22 +103,6 @@ setAppState(APPSTATE.CHANNELS + "#" + channel.name); }; - // LEADERBOARD - let leaderboard: Array = []; - - export async function getLeader(): Promise { - let response = await fetch(API_URL + "/leaderboard", { - credentials: "include", - mode: "cors", - }); - return await response.json(); - } - - async function clickLeaderboard() { - leaderboard = await getLeader(); - setAppState(APPSTATE.LEADERBOARD); - } - // GAME let pong: Pong; @@ -214,21 +165,12 @@ {/if} {#if appState === APPSTATE.LEADERBOARD}
- +
{/if} {#if appState === APPSTATE.FRIENDS} -
{ - resetAppState(); - clearInterval(friendsInterval); - }} - on:keydown={() => { - resetAppState(); - clearInterval(friendsInterval); - }} - > - +
+
{/if} {#if appState === APPSTATE.HISTORY} @@ -241,12 +183,12 @@ on:click={() => setAppState(APPSTATE.PROFILE)} on:keydown={() => setAppState(APPSTATE.PROFILE)} > - +
{/if} {#if appState === APPSTATE.PROFILE}
- +
{/if} {#if appState === APPSTATE.PROFILE_ID} @@ -256,7 +198,7 @@ on:keydown={() => setAppState(APPSTATE.CHANNELS + "#" + selectedChannel.name)} > - + {/if} diff --git a/front/volume/src/components/Friends.svelte b/front/volume/src/components/Friends.svelte index 82717fc..338398c 100644 --- a/front/volume/src/components/Friends.svelte +++ b/front/volume/src/components/Friends.svelte @@ -26,32 +26,67 @@
+

{$store.username} friends:

{#if friends.length > 0} -

Monkey friends

- {#each friends.slice(0, 10) as friend} +
+ {#each friends as friend}
  • {friend.username} is {friend.status}
  • {/each} + /> +
    {:else}

    No friends to display

    {/if} +

    {$store.username} invits:

    {#if invits.length > 0} -

    Monkey invits

    - {#each invits.slice(0, 10) as invit} +
    + {#each invits as invit}
  • {invit.username} invited you to be friend.
  • {/each} +
    {:else}

    No invitations to display

    {/if} @@ -87,4 +122,10 @@ padding: 1rem; width: 300px; } + + .friends-list, + .invits-list { + overflow-y: scroll; + max-height: 200px; + } diff --git a/front/volume/src/components/Leaderboard.svelte b/front/volume/src/components/Leaderboard.svelte index 52a23d0..05f7516 100644 --- a/front/volume/src/components/Leaderboard.svelte +++ b/front/volume/src/components/Leaderboard.svelte @@ -1,7 +1,21 @@
    @@ -21,13 +35,13 @@ Matchs Winrates - {#each leaderboard.slice(0, 10) as player} + {#each leaderboard as player} {player.rank} {player.username} {player.wins} {player.matchs} - {player.winrate}% + {player.winrate.toFixed(2)}% {/each} @@ -60,6 +74,8 @@ width: 300px; display: flex; justify-content: center; + max-height: 500px; + overflow-y: scroll; } td { diff --git a/front/volume/src/components/MatchHistory.svelte b/front/volume/src/components/MatchHistory.svelte index b166b57..e612462 100644 --- a/front/volume/src/components/MatchHistory.svelte +++ b/front/volume/src/components/MatchHistory.svelte @@ -115,7 +115,7 @@ display: flex; justify-content: center; max-height: 500px; - overflow-x: scroll; + overflow-y: scroll; } td { diff --git a/front/volume/src/components/Profile.svelte b/front/volume/src/components/Profile.svelte index 1124cf9..ce81e2d 100644 --- a/front/volume/src/components/Profile.svelte +++ b/front/volume/src/components/Profile.svelte @@ -11,14 +11,30 @@