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)]
|
#[ts(export)]
|
||||||
pub struct FriendshipResponseDto {
|
pub struct FriendshipResponseDto {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub friend: UserBasicDto,
|
pub friend: Option<UserBasicDto>,
|
||||||
pub created_at: String,
|
pub created_at: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,4 +39,4 @@ pub struct FriendRequestResponseDto {
|
|||||||
pub status: String,
|
pub status: String,
|
||||||
pub created_at: String,
|
pub created_at: String,
|
||||||
pub updated_at: String,
|
pub updated_at: String,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -303,23 +303,29 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
{#each friends as friend (friend.id)}
|
{#each friends as friend (friend.id)}
|
||||||
<div class="card px-3 py-2 bg-base-200/50">
|
{#if friend.friend}
|
||||||
<div class="flex items-center justify-between">
|
<div class="card px-3 py-2 bg-base-200/50">
|
||||||
<div>
|
<div class="flex items-center justify-between">
|
||||||
<div class="font-light">{friend.friend.name}</div>
|
<div>
|
||||||
<div class="text-xs text-base-content/70">
|
<div class="font-light">{friend.friend.name}</div>
|
||||||
@{friend.friend.username ?? "unknown"}
|
<div class="text-xs text-base-content/70">
|
||||||
|
@{friend.friend.username ?? "unknown"}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<button
|
||||||
|
class="btn btn-sm btn-outline"
|
||||||
|
disabled={loading.action}
|
||||||
|
on:click={() => {
|
||||||
|
friend.friend
|
||||||
|
? handleUnfriend(friend.friend.id)
|
||||||
|
: null;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Unfriend
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button
|
|
||||||
class="btn btn-sm btn-outline"
|
|
||||||
disabled={loading.action}
|
|
||||||
on:click={() => handleUnfriend(friend.friend.id)}
|
|
||||||
>
|
|
||||||
Unfriend
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
let isInteractive = $derived($sceneInteractive);
|
let isInteractive = $derived($sceneInteractive);
|
||||||
|
|
||||||
function getFriendById(userId: string) {
|
function getFriendById(userId: string) {
|
||||||
const friend = $appData?.friends?.find((f) => f.friend.id === userId);
|
const friend = $appData?.friends?.find((f) => f.friend?.id === userId);
|
||||||
return friend!.friend;
|
return friend?.friend;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFriendDoll(userId: string) {
|
function getFriendDoll(userId: string) {
|
||||||
@@ -32,8 +32,8 @@
|
|||||||
return $friendsActiveDolls[userId];
|
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;
|
return friend?.friend?.activeDoll;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFriendStatus(userId: string) {
|
function getFriendStatus(userId: string) {
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
{#each Object.entries($friendsCursorPositions) as [userId, position]}
|
{#each Object.entries($friendsCursorPositions) as [userId, position]}
|
||||||
{@const status = getFriendStatus(userId)}
|
{@const status = getFriendStatus(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">{getFriendById(userId).name}</span>
|
<span class="font-bold">{getFriendById(userId)?.name}</span>
|
||||||
<div class="flex flex-row font-mono gap-2">
|
<div class="flex flex-row font-mono gap-2">
|
||||||
<span>
|
<span>
|
||||||
({position.mapped.x.toFixed(3)}, {position.mapped.y.toFixed(
|
({position.mapped.x.toFixed(3)}, {position.mapped.y.toFixed(
|
||||||
@@ -143,12 +143,13 @@
|
|||||||
{#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 doll = getFriendDoll(userId)}
|
{@const doll = getFriendDoll(userId)}
|
||||||
{#if doll}
|
{@const friend = getFriendById(userId)}
|
||||||
|
{#if doll && friend}
|
||||||
<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}
|
||||||
user={getFriendById(userId)}
|
user={friend}
|
||||||
userStatus={getFriendStatus(userId)}
|
userStatus={getFriendStatus(userId)}
|
||||||
{doll}
|
{doll}
|
||||||
{isInteractive}
|
{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.
|
// 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";
|
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