diff --git a/apps/client/src/lib/components/ChatArea.svelte b/apps/client/src/lib/components/ChatArea.svelte index b99fa51..eced5c5 100644 --- a/apps/client/src/lib/components/ChatArea.svelte +++ b/apps/client/src/lib/components/ChatArea.svelte @@ -64,6 +64,16 @@ chatArea.scrollTo({top: chatArea.scrollHeight, behavior: "smooth"}); } + + function handleEmoteClick(ev: CustomEvent) { + if (!messageInputEl || !ev.detail) { + console.error("Missing message input or emote detail"); + return; + } + + const {name} = ev.detail; + messageInputEl.value += `:${name}:`; + } @@ -88,6 +98,6 @@ - + diff --git a/apps/client/src/lib/components/EmoteActions.svelte b/apps/client/src/lib/components/EmoteActions.svelte index 76010b1..38703e9 100644 --- a/apps/client/src/lib/components/EmoteActions.svelte +++ b/apps/client/src/lib/components/EmoteActions.svelte @@ -1,7 +1,13 @@ -
@@ -33,9 +45,14 @@
-
- Emotes +
+ {#each Object.keys($emotes) as key ($emotes[key].id)} + + {/each}
-
\ No newline at end of file +
diff --git a/apps/client/src/lib/emote-parser.ts b/apps/client/src/lib/emote-parser.ts index 4b13be4..a825596 100644 --- a/apps/client/src/lib/emote-parser.ts +++ b/apps/client/src/lib/emote-parser.ts @@ -3,6 +3,7 @@ import {fetchSevenTVEmotes} from "$lib/seven-tv-adapter"; export type EmoteSet = Record; export type Emote = { + id: string; name: string; host: string; files: Record; @@ -23,7 +24,7 @@ const sizes = { } as const; export function parseMessage(emotes: EmoteSet, message: string) { - const emoteRegex = /:(.*):/g; + const emoteRegex = /:(.*?):/gm; const emoteMatches = message.matchAll(emoteRegex); let parsedMessage = message; @@ -40,6 +41,5 @@ export function parseMessage(emotes: EmoteSet, message: string) { export async function fetchEmotes() { const emotes = await fetchSevenTVEmotes(); - console.log() return emotes; } diff --git a/apps/client/src/lib/seven-tv-adapter.ts b/apps/client/src/lib/seven-tv-adapter.ts index 3210e9a..32de0f4 100644 --- a/apps/client/src/lib/seven-tv-adapter.ts +++ b/apps/client/src/lib/seven-tv-adapter.ts @@ -5,6 +5,7 @@ type SevenTvEmoteSetResponse = { } type SevenTvEmoteSet = { + id: string; name: string; data: { host: { @@ -44,6 +45,7 @@ export async function fetchSevenTVEmotes() { }, {} as Record); acc[emote.name] = { + id: emote.id, name: emote.name, host: emote.data.host.url, files diff --git a/apps/client/src/routes/+layout.svelte b/apps/client/src/routes/+layout.svelte index 62383c5..ed66485 100644 --- a/apps/client/src/routes/+layout.svelte +++ b/apps/client/src/routes/+layout.svelte @@ -13,7 +13,7 @@ const emoteStore = getEmoteStore(); async function init() { - const emotes = await fetchEmotes() as any; + const emotes = await fetchEmotes(); emoteStore.set(emotes); }