diff --git a/front/volume/src/App.svelte b/front/volume/src/App.svelte index a6f04a3..e0add26 100644 --- a/front/volume/src/App.svelte +++ b/front/volume/src/App.svelte @@ -81,7 +81,6 @@ return null; } - let chan: Channels; async function openDirectChat(event: CustomEvent) { const DMUsername = event.detail; let DMChannel: Array = []; @@ -89,41 +88,43 @@ if (res && res.ok) { DMChannel = await res.json(); if (DMChannel.length != 0) - chan.selectChat(DMChannel[0].id); + await formatChannelNames(DMChannel) + setAppState(APPSTATE.CHANNELS + "#" + DMChannel[0].name) } else { - console.log("Creating DMChannel: " + $store.username + "&" + DMUsername) - fetch(API_URL + "/channels", { - credentials: "include", - method: "POST", - mode: "cors", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - name: "none", - owner: $store.ftId, - password: "", - isPrivate: true, - isDM: true, - otherDMedUsername: DMUsername - }), - }).then(async () => { - const response = await getDMs(DMUsername) - if (response && response.ok) { - DMChannel = await response.json(); - if (DMChannel.length != 0) { - chan.selectChat(DMChannel[0].id); - } else { - alert("Error creating DM"); - } - } else { - alert("Error creating DM"); - } - }).catch((error) => { + console.log("Creating DMChannel: " + $store.username + "&" + DMUsername) + fetch(API_URL + "/channels", { + credentials: "include", + method: "POST", + mode: "cors", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + name: "none", + owner: $store.ftId, + password: "", + isPrivate: true, + isDM: true, + otherDMedUsername: DMUsername + }), + }).then(async () => { + const response = await getDMs(DMUsername) + if (response && response.ok) { + DMChannel = await response.json(); + if (DMChannel.length != 0) { + await formatChannelNames(DMChannel) + setAppState(APPSTATE.CHANNELS + "#" + DMChannel[0].name) + } else { + alert("Error creating DM"); + } + } else { alert("Error creating DM"); - }) - } + } + }).catch(() => { + alert("Error creating DM"); + }) } + } async function clickHistory() { setAppState(APPSTATE.HISTORY); @@ -192,20 +193,23 @@ {clickLeaderboard} /> {#if appState.includes(`${APPSTATE.CHANNELS}#`)} -
setAppState(APPSTATE.CHANNELS)} - on:keydown={() => setAppState(APPSTATE.CHANNELS)} - > - -
+ {#key appState} +
setAppState(APPSTATE.CHANNELS)} + on:keydown={() => setAppState(APPSTATE.CHANNELS)} + > + +
+ {/key} {/if} {#if appState.includes(APPSTATE.CHANNELS)}
- +
{/if} {#if appState === APPSTATE.LEADERBOARD} diff --git a/front/volume/src/components/Channels.svelte b/front/volume/src/components/Channels.svelte index 7888095..add9430 100644 --- a/front/volume/src/components/Channels.svelte +++ b/front/volume/src/components/Channels.svelte @@ -281,8 +281,7 @@ border-radius: 5px; padding: 1rem; width: 500px; - overflow-y: scroll; - overflow-x: auto; + overflow: auto; max-height: 80%; } diff --git a/front/volume/src/components/Chat.svelte b/front/volume/src/components/Chat.svelte index baff9b8..55a795d 100644 --- a/front/volume/src/components/Chat.svelte +++ b/front/volume/src/components/Chat.svelte @@ -4,26 +4,49 @@ import { io, Socket } from "socket.io-client"; import { show_popup, content } from "./Alert/content"; import { APPSTATE } from "../App.svelte"; - import type { ChannelsType, chatMessagesType } from "./Channels.svelte"; + import { formatChannelNames, type ChannelsType, type chatMessagesType } from "./Channels.svelte"; import type User from "./Profile.svelte";