updated friend field to be optional (frontend bug fix, not that I have
no friends)
This commit is contained in:
@@ -18,7 +18,7 @@ pub struct UserBasicDto {
|
||||
#[ts(export)]
|
||||
pub struct FriendshipResponseDto {
|
||||
pub id: String,
|
||||
pub friend: UserBasicDto,
|
||||
pub friend: Option<UserBasicDto>,
|
||||
pub created_at: String,
|
||||
}
|
||||
|
||||
|
||||
@@ -303,23 +303,29 @@
|
||||
{:else}
|
||||
<div class="flex flex-col gap-2">
|
||||
{#each friends as friend (friend.id)}
|
||||
<div class="card px-3 py-2 bg-base-200/50">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<div class="font-light">{friend.friend.name}</div>
|
||||
<div class="text-xs text-base-content/70">
|
||||
@{friend.friend.username ?? "unknown"}
|
||||
{#if friend.friend}
|
||||
<div class="card px-3 py-2 bg-base-200/50">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<div class="font-light">{friend.friend.name}</div>
|
||||
<div class="text-xs text-base-content/70">
|
||||
@{friend.friend.username ?? "unknown"}
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
class="btn btn-sm btn-outline"
|
||||
disabled={loading.action}
|
||||
on:click={() => {
|
||||
friend.friend
|
||||
? handleUnfriend(friend.friend.id)
|
||||
: null;
|
||||
}}
|
||||
>
|
||||
Unfriend
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
class="btn btn-sm btn-outline"
|
||||
disabled={loading.action}
|
||||
on:click={() => handleUnfriend(friend.friend.id)}
|
||||
>
|
||||
Unfriend
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
let isInteractive = $derived($sceneInteractive);
|
||||
|
||||
function getFriendById(userId: string) {
|
||||
const friend = $appData?.friends?.find((f) => f.friend.id === userId);
|
||||
return friend!.friend;
|
||||
const friend = $appData?.friends?.find((f) => f.friend?.id === userId);
|
||||
return friend?.friend;
|
||||
}
|
||||
|
||||
function getFriendDoll(userId: string) {
|
||||
@@ -32,8 +32,8 @@
|
||||
return $friendsActiveDolls[userId];
|
||||
}
|
||||
|
||||
const friend = $appData?.friends?.find((f) => f.friend.id === userId);
|
||||
return friend?.friend.activeDoll;
|
||||
const friend = $appData?.friends?.find((f) => f.friend?.id === userId);
|
||||
return friend?.friend?.activeDoll;
|
||||
}
|
||||
|
||||
function getFriendStatus(userId: string) {
|
||||
@@ -109,7 +109,7 @@
|
||||
{#each Object.entries($friendsCursorPositions) as [userId, position]}
|
||||
{@const status = getFriendStatus(userId)}
|
||||
<div class="badge py-3 text-xs text-left flex flex-row gap-2">
|
||||
<span class="font-bold">{getFriendById(userId).name}</span>
|
||||
<span class="font-bold">{getFriendById(userId)?.name}</span>
|
||||
<div class="flex flex-row font-mono gap-2">
|
||||
<span>
|
||||
({position.mapped.x.toFixed(3)}, {position.mapped.y.toFixed(
|
||||
@@ -143,12 +143,13 @@
|
||||
{#if Object.keys($friendsCursorPositions).length > 0}
|
||||
{#each Object.entries($friendsCursorPositions) as [userId, position]}
|
||||
{@const doll = getFriendDoll(userId)}
|
||||
{#if doll}
|
||||
{@const friend = getFriendById(userId)}
|
||||
{#if doll && friend}
|
||||
<DesktopPet
|
||||
id={userId}
|
||||
targetX={position.mapped.x * innerWidth}
|
||||
targetY={position.mapped.y * innerHeight}
|
||||
user={getFriendById(userId)}
|
||||
user={friend}
|
||||
userStatus={getFriendStatus(userId)}
|
||||
{doll}
|
||||
{isInteractive}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { UserBasicDto } from "./UserBasicDto";
|
||||
|
||||
export type FriendshipResponseDto = { id: string, friend: UserBasicDto, createdAt: string, };
|
||||
export type FriendshipResponseDto = { id: string, friend: UserBasicDto | null, createdAt: string, };
|
||||
|
||||
Reference in New Issue
Block a user