diff --git a/src/routes/scene/+page.svelte b/src/routes/scene/+page.svelte index 20e8229..7c8ce10 100644 --- a/src/routes/scene/+page.svelte +++ b/src/routes/scene/+page.svelte @@ -13,45 +13,13 @@ import DebugBar from "./components/debug-bar.svelte"; import Neko from "./components/neko/neko.svelte"; import PetMenu from "./components/pet-menu.svelte"; + import { createPetActions } from "./components/pet-menu/events"; + import type { UserBasicDto } from "$lib/bindings"; - function createPetActions(name: string) { - // TODO: replace `name` with full user object, onClicks with proper actions - return [ - { - icon: "👋", - label: `Wave at ${name}`, - onClick: () => { - console.log(`Wave at ${name}`); - }, - }, - { - icon: "💬", - label: `Message ${name}`, - onClick: () => { - console.log(`Message ${name}`); - }, - }, - { - icon: "🔔", - label: `Ping ${name}`, - onClick: () => { - console.log(`Ping ${name}`); - }, - }, - { - icon: "🔎", - label: `Inspect ${name}`, - onClick: () => { - console.log(`Inspect ${name}`); - }, - }, - ]; - } - - function getFriendName(friendId: string) { + function getFriend(friendId: string): UserBasicDto | undefined { return ( ($appData?.friends ?? []).find((friend) => friend.friend?.id === friendId) - ?.friend?.name || friendId + ?.friend ?? undefined ); } @@ -73,7 +41,7 @@ {/if} {#each Object.entries($friendsCursorPositions) as [friendId, position] (friendId)} {#if $friendActiveDollSpriteUrls[friendId]} - {@const friendName = getFriendName(friendId)} + {@const friend = getFriend(friendId)} {/if} diff --git a/src/routes/scene/components/pet-menu/events.ts b/src/routes/scene/components/pet-menu/events.ts index 907932c..71b5863 100644 --- a/src/routes/scene/components/pet-menu/events.ts +++ b/src/routes/scene/components/pet-menu/events.ts @@ -1,5 +1,40 @@ +import type { UserBasicDto } from "$lib/bindings"; + export type CloseHandler = () => void; +export function createPetActions(user: UserBasicDto) { + return [ + { + icon: "👋", + label: `Wave at ${user.name}`, + onClick: () => { + console.log(`Wave at ${user.name}`); + }, + }, + { + icon: "💬", + label: `Message ${user.name}`, + onClick: () => { + console.log(`Message ${user.name}`); + }, + }, + { + icon: "🔔", + label: `Ping ${user.name}`, + onClick: () => { + console.log(`Ping ${user.name}`); + }, + }, + { + icon: "🔎", + label: `Inspect ${user.name}`, + onClick: () => { + console.log(`Inspect ${user.name}`); + }, + }, + ]; +} + export function createDocumentPointerHandler( isOpen: () => boolean, rootEl: () => HTMLDivElement | null,