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