updated friend doll retrieval return type
This commit is contained in:
@@ -21,13 +21,13 @@
|
||||
return friend ? friend.friend.name : userId.slice(0, 8) + "...";
|
||||
}
|
||||
|
||||
function getFriendDollConfig(userId: string) {
|
||||
function getFriendDoll(userId: string) {
|
||||
if (userId in $friendsActiveDolls) {
|
||||
return $friendsActiveDolls[userId]?.configuration;
|
||||
return $friendsActiveDolls[userId];
|
||||
}
|
||||
|
||||
const friend = $appData?.friends?.find((f) => f.friend.id === userId);
|
||||
return friend?.friend.activeDoll?.configuration;
|
||||
return friend?.friend.activeDoll;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<div class="flex flex-col gap-2">
|
||||
<div>
|
||||
{#each Object.entries($friendsCursorPositions) as [userId, position]}
|
||||
{@const dollConfig = getFriendDollConfig(userId)}
|
||||
{@const dollConfig = getFriendDoll(userId)}
|
||||
<div class="badge py-3 text-xs text-left flex flex-row gap-2">
|
||||
<span class="font-bold">{getFriendName(userId)}</span>
|
||||
<div class="flex flex-col font-mono">
|
||||
@@ -88,14 +88,14 @@
|
||||
<div class="absolute inset-0 size-full">
|
||||
{#if Object.keys($friendsCursorPositions).length > 0}
|
||||
{#each Object.entries($friendsCursorPositions) as [userId, position]}
|
||||
{@const config = getFriendDollConfig(userId)}
|
||||
{#if config}
|
||||
{@const doll = getFriendDoll(userId)}
|
||||
{#if doll}
|
||||
<DesktopPet
|
||||
id={userId}
|
||||
targetX={position.mapped.x * innerWidth}
|
||||
targetY={position.mapped.y * innerHeight}
|
||||
name={getFriendName(userId)}
|
||||
{config}
|
||||
{doll}
|
||||
{isInteractive}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
import PetSprite from "$lib/components/PetSprite.svelte";
|
||||
import onekoGif from "../../../assets/oneko/oneko.gif";
|
||||
import PetMenu from "./PetMenu.svelte";
|
||||
import type { DollConfigurationDto } from "../../../types/bindings/DollConfigurationDto";
|
||||
import type { DollDto } from "../../../types/bindings/DollDto";
|
||||
|
||||
export let id = "";
|
||||
export let targetX = 0;
|
||||
export let targetY = 0;
|
||||
export let name = "";
|
||||
export let config: DollConfigurationDto | undefined = undefined;
|
||||
export let doll: DollDto | undefined = undefined;
|
||||
export let isInteractive = false;
|
||||
|
||||
const { position, currentSprite, updatePosition, setPosition } = usePetState(
|
||||
@@ -27,7 +27,7 @@
|
||||
let isPetMenuOpen = false;
|
||||
|
||||
// Watch for color changes to regenerate sprite
|
||||
$: updateSprite(config?.colorScheme.body, config?.colorScheme.outline);
|
||||
$: updateSprite(doll?.configuration.colorScheme.body, doll?.configuration.colorScheme.outline);
|
||||
|
||||
$: (isInteractive, (isPetMenuOpen = false));
|
||||
|
||||
@@ -92,8 +92,8 @@
|
||||
tabindex="0"
|
||||
aria-label="Pet Menu"
|
||||
>
|
||||
{#if config}
|
||||
<PetMenu {config} />
|
||||
{#if doll}
|
||||
<PetMenu {doll} />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { type DollConfigurationDto } from "../../../types/bindings/DollConfigurationDto";
|
||||
export let config: DollConfigurationDto;
|
||||
import { type DollDto } from "../../../types/bindings/DollDto";
|
||||
export let doll: DollDto;
|
||||
</script>
|
||||
|
||||
<div class="bg-base-100 border border-base-200 card p-1">
|
||||
<div class="flex flex-col gap-1">
|
||||
<p class="text-xs">{config.colorScheme.body}</p>
|
||||
<p class="text-xs">{doll.name}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user