|
@ -3,6 +3,7 @@ |
|
|
HOME = "/", |
|
|
HOME = "/", |
|
|
PROFILE = "/profile", |
|
|
PROFILE = "/profile", |
|
|
HISTORY = "/history", |
|
|
HISTORY = "/history", |
|
|
|
|
|
HISTORY_ID = "/history_id", |
|
|
FRIENDS = "/friends", |
|
|
FRIENDS = "/friends", |
|
|
SPECTATE = "/spectate", |
|
|
SPECTATE = "/spectate", |
|
|
CHANNELS = "/channels", |
|
|
CHANNELS = "/channels", |
|
@ -61,6 +62,7 @@ |
|
|
setInterval(() => { |
|
|
setInterval(() => { |
|
|
getUser(); |
|
|
getUser(); |
|
|
}, 15000); |
|
|
}, 15000); |
|
|
|
|
|
|
|
|
function clickProfile() { |
|
|
function clickProfile() { |
|
|
setAppState(APPSTATE.PROFILE); |
|
|
setAppState(APPSTATE.PROFILE); |
|
|
} |
|
|
} |
|
@ -80,12 +82,13 @@ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// HISTORY |
|
|
// HISTORY |
|
|
let matches: Array<Match>; |
|
|
|
|
|
async function clickHistory() { |
|
|
async function clickHistory() { |
|
|
setAppState(APPSTATE.HISTORY); |
|
|
setAppState(APPSTATE.HISTORY); |
|
|
matches = await getHistory(); |
|
|
matches = await getHistory(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let matches: Array<Match>; |
|
|
|
|
|
|
|
|
export async function getHistory(): Promise<Array<Match>> { |
|
|
export async function getHistory(): Promise<Array<Match>> { |
|
|
let response = await fetch(API_URL + "/rankedHistory/", { |
|
|
let response = await fetch(API_URL + "/rankedHistory/", { |
|
|
credentials: "include", |
|
|
credentials: "include", |
|
@ -94,19 +97,29 @@ |
|
|
return await response.json(); |
|
|
return await response.json(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function openIdHistory(event: CustomEvent<string>) { |
|
|
|
|
|
console.log("Opening history: " + event.detail); |
|
|
|
|
|
const res = await fetch(API_URL + "/history/" + event.detail, { |
|
|
|
|
|
credentials: "include", |
|
|
|
|
|
mode: "cors", |
|
|
|
|
|
}); |
|
|
|
|
|
matches = await res.json(); |
|
|
|
|
|
setAppState(APPSTATE.HISTORY_ID); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// FRIENDS |
|
|
// FRIENDS |
|
|
let friends: Friend[] = []; |
|
|
let friends: Friend[] = []; |
|
|
let invits: Friend[] = []; |
|
|
let invits: Friend[] = []; |
|
|
let friendsInterval: ReturnType<typeof setInterval>; |
|
|
let friendsInterval: ReturnType<typeof setInterval>; |
|
|
|
|
|
|
|
|
export async function getFriends(): Promise<Friend[]> { |
|
|
async function getFriends(): Promise<Friend[]> { |
|
|
let response = await fetch(API_URL + "/friends", { |
|
|
let response = await fetch(API_URL + "/friends", { |
|
|
credentials: "include", |
|
|
credentials: "include", |
|
|
mode: "cors", |
|
|
mode: "cors", |
|
|
}); |
|
|
}); |
|
|
return await response.json(); |
|
|
return await response.json(); |
|
|
} |
|
|
} |
|
|
export async function getInvits(): Promise<Friend[]> { |
|
|
async function getInvits(): Promise<Friend[]> { |
|
|
let response = await fetch(API_URL + "/invits", { |
|
|
let response = await fetch(API_URL + "/invits", { |
|
|
credentials: "include", |
|
|
credentials: "include", |
|
|
mode: "cors", |
|
|
mode: "cors", |
|
@ -235,14 +248,23 @@ |
|
|
<MatchHistory {matches} /> |
|
|
<MatchHistory {matches} /> |
|
|
</div> |
|
|
</div> |
|
|
{/if} |
|
|
{/if} |
|
|
|
|
|
{#if appState === APPSTATE.HISTORY_ID} |
|
|
|
|
|
<div on:click={resetAppState} on:keydown={resetAppState}> |
|
|
|
|
|
<MatchHistory {matches} /> |
|
|
|
|
|
</div> |
|
|
|
|
|
{/if} |
|
|
{#if appState === APPSTATE.PROFILE} |
|
|
{#if appState === APPSTATE.PROFILE} |
|
|
<div on:click={resetAppState} on:keydown={resetAppState}> |
|
|
<div on:click={resetAppState} on:keydown={resetAppState}> |
|
|
<Profile user={$store} edit={1} /> |
|
|
<Profile user={$store} edit={1} |
|
|
|
|
|
on:view-history={openIdHistory} |
|
|
|
|
|
/> |
|
|
</div> |
|
|
</div> |
|
|
{/if} |
|
|
{/if} |
|
|
{#if appState === APPSTATE.PROFILE_ID} |
|
|
{#if appState === APPSTATE.PROFILE_ID} |
|
|
<div on:click={resetAppState} on:keydown={resetAppState}> |
|
|
<div on:click={resetAppState} on:keydown={resetAppState}> |
|
|
<Profile user={userProfile} edit={0} /> |
|
|
<Profile user={userProfile} edit={0} |
|
|
|
|
|
on:view-history={openIdHistory} |
|
|
|
|
|
/> |
|
|
</div> |
|
|
</div> |
|
|
{/if} |
|
|
{/if} |
|
|
|
|
|
|
|
|