2025-10-25 22:04:41 +02:00
|
|
|
<script lang="ts">
|
2026-03-08 11:31:51 +01:00
|
|
|
import { untrack } from "svelte";
|
2026-03-04 22:27:54 +01:00
|
|
|
import { _ } from "svelte-i18n";
|
|
|
|
|
import { Button } from "$lib/components/ui/button";
|
|
|
|
|
import { Card, CardContent } from "$lib/components/ui/card";
|
|
|
|
|
import "media-chrome";
|
2026-03-05 10:19:05 +01:00
|
|
|
import { getAssetUrl } from "$lib/api";
|
2026-03-04 22:27:54 +01:00
|
|
|
import TimeAgo from "javascript-time-ago";
|
|
|
|
|
import { page } from "$app/state";
|
2026-03-06 19:25:07 +01:00
|
|
|
import SexyBackground from "$lib/components/background/background.svelte";
|
2026-03-04 22:27:54 +01:00
|
|
|
import Meta from "$lib/components/meta/meta.svelte";
|
|
|
|
|
import * as Alert from "$lib/components/ui/alert";
|
|
|
|
|
import Textarea from "$lib/components/ui/textarea/textarea.svelte";
|
|
|
|
|
import Avatar from "$lib/components/ui/avatar/avatar.svelte";
|
|
|
|
|
import { AvatarFallback, AvatarImage } from "$lib/components/ui/avatar";
|
|
|
|
|
import { formatVideoDuration, getUserInitials } from "$lib/utils";
|
|
|
|
|
import { invalidateAll } from "$app/navigation";
|
|
|
|
|
import { toast } from "svelte-sonner";
|
|
|
|
|
import {
|
|
|
|
|
createCommentForVideo,
|
2026-03-07 11:19:50 +01:00
|
|
|
deleteComment,
|
2026-03-04 22:27:54 +01:00
|
|
|
likeVideo,
|
|
|
|
|
unlikeVideo,
|
|
|
|
|
recordVideoPlay,
|
|
|
|
|
updateVideoPlay,
|
|
|
|
|
} from "$lib/services";
|
|
|
|
|
import SharingPopupButton from "$lib/components/sharing-popup/sharing-popup-button.svelte";
|
2025-10-25 22:04:41 +02:00
|
|
|
|
2026-03-04 22:27:54 +01:00
|
|
|
const { data } = $props();
|
2025-10-28 10:31:06 +01:00
|
|
|
|
2026-03-04 22:27:54 +01:00
|
|
|
const timeAgo = new TimeAgo("en");
|
2026-03-08 11:31:51 +01:00
|
|
|
let isLiked = $state(untrack(() => data.likeStatus.liked));
|
|
|
|
|
let likesCount = $state(untrack(() => data.video.likes_count || 0));
|
2026-03-08 11:06:30 +01:00
|
|
|
$effect(() => {
|
|
|
|
|
isLiked = data.likeStatus.liked;
|
|
|
|
|
likesCount = data.video.likes_count || 0;
|
|
|
|
|
});
|
2026-03-04 22:27:54 +01:00
|
|
|
let isLikeLoading = $state(false);
|
|
|
|
|
let newComment = $state("");
|
|
|
|
|
let showComments = $state(true);
|
|
|
|
|
let isCommentLoading = $state(false);
|
|
|
|
|
let isCommentError = $state(false);
|
|
|
|
|
let commentError = $state();
|
|
|
|
|
let currentPlayId = $state<string | null>(null);
|
|
|
|
|
let lastTrackedTime = $state(0);
|
2025-10-25 22:04:41 +02:00
|
|
|
|
2026-03-04 22:27:54 +01:00
|
|
|
async function handleLike() {
|
|
|
|
|
if (!data.authStatus.authenticated) {
|
|
|
|
|
toast.error("Please sign in to like videos");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-10-28 10:31:06 +01:00
|
|
|
|
2026-03-04 22:27:54 +01:00
|
|
|
try {
|
|
|
|
|
isLikeLoading = true;
|
|
|
|
|
if (isLiked) {
|
|
|
|
|
const result = await unlikeVideo(data.video.id);
|
|
|
|
|
likesCount = result.likes_count;
|
|
|
|
|
isLiked = false;
|
|
|
|
|
toast.success("Removed from liked videos");
|
|
|
|
|
} else {
|
|
|
|
|
const result = await likeVideo(data.video.id);
|
|
|
|
|
likesCount = result.likes_count;
|
|
|
|
|
isLiked = true;
|
|
|
|
|
toast.success("Added to liked videos");
|
|
|
|
|
}
|
2026-03-07 19:25:04 +01:00
|
|
|
} catch (error) {
|
|
|
|
|
toast.error((error instanceof Error ? error.message : null) || "Failed to update like");
|
2026-03-04 22:27:54 +01:00
|
|
|
} finally {
|
|
|
|
|
isLikeLoading = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-25 22:04:41 +02:00
|
|
|
|
2026-03-07 11:19:50 +01:00
|
|
|
async function handleDeleteComment(id: number) {
|
|
|
|
|
try {
|
|
|
|
|
await deleteComment(id);
|
|
|
|
|
toast.success($_("videos.comment_deleted"));
|
|
|
|
|
invalidateAll();
|
|
|
|
|
} catch {
|
|
|
|
|
toast.error($_("videos.comment_delete_error"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 22:27:54 +01:00
|
|
|
async function handleComment(e: Event) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
try {
|
|
|
|
|
isCommentLoading = true;
|
|
|
|
|
isCommentError = false;
|
|
|
|
|
commentError = "";
|
|
|
|
|
await createCommentForVideo(data.video.id, newComment);
|
|
|
|
|
toast.success($_("videos.toast_comment"));
|
|
|
|
|
invalidateAll();
|
|
|
|
|
newComment = "";
|
|
|
|
|
showComments = true;
|
2026-03-07 19:25:04 +01:00
|
|
|
} catch (err) {
|
|
|
|
|
commentError = err instanceof Error ? err.message : "Unknown error";
|
2026-03-04 22:27:54 +01:00
|
|
|
isCommentError = true;
|
|
|
|
|
} finally {
|
|
|
|
|
isCommentLoading = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-25 22:04:41 +02:00
|
|
|
|
2026-03-04 22:27:54 +01:00
|
|
|
async function handlePlay() {
|
|
|
|
|
showPlayer = true;
|
|
|
|
|
try {
|
|
|
|
|
const result = await recordVideoPlay(data.video.id);
|
|
|
|
|
currentPlayId = result.play_id;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Failed to record play:", error);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-25 22:04:41 +02:00
|
|
|
|
2026-03-04 22:27:54 +01:00
|
|
|
function handleTimeUpdate(e: Event) {
|
|
|
|
|
const video = e.target as HTMLVideoElement;
|
|
|
|
|
const currentTime = Math.floor(video.currentTime);
|
2025-10-28 10:31:06 +01:00
|
|
|
|
2026-03-04 22:27:54 +01:00
|
|
|
// Update every 10 seconds
|
|
|
|
|
if (currentPlayId && currentTime - lastTrackedTime >= 10) {
|
|
|
|
|
lastTrackedTime = currentTime;
|
|
|
|
|
const completed = video.currentTime >= video.duration * 0.9; // 90% watched = completed
|
|
|
|
|
updateVideoPlay(data.video.id, currentPlayId, currentTime, completed).catch(console.error);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-28 10:31:06 +01:00
|
|
|
|
2026-03-04 22:27:54 +01:00
|
|
|
let showPlayer = $state(false);
|
2025-10-25 22:04:41 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<Meta
|
|
|
|
|
title={data.video.title}
|
|
|
|
|
description={data.video.description}
|
2026-03-04 22:27:54 +01:00
|
|
|
image={getAssetUrl(data.video.image, "medium")!}
|
2025-10-25 22:04:41 +02:00
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
class="relative min-h-screen bg-gradient-to-br from-background via-primary/5 to-accent/5 overflow-hidden"
|
|
|
|
|
>
|
2026-03-06 19:25:07 +01:00
|
|
|
<SexyBackground />
|
2025-10-25 22:04:41 +02:00
|
|
|
<div class="container mx-auto px-4 py-8">
|
|
|
|
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
|
|
|
|
<!-- Main Video Section -->
|
|
|
|
|
<div class="lg:col-span-2 space-y-6">
|
|
|
|
|
<!-- Video Player -->
|
2026-03-04 22:27:54 +01:00
|
|
|
<Card class="p-0 overflow-hidden bg-gradient-to-br from-card to-card/50">
|
2025-10-25 22:04:41 +02:00
|
|
|
<div class="relative aspect-video bg-black">
|
|
|
|
|
{#if showPlayer}
|
2026-03-04 21:41:07 +01:00
|
|
|
<media-controller class="absolute inset-0 w-full h-full">
|
2025-10-25 22:04:41 +02:00
|
|
|
<video
|
|
|
|
|
slot="media"
|
2026-03-04 21:27:06 +01:00
|
|
|
src={getAssetUrl(data.video.movie)}
|
2026-03-04 22:27:54 +01:00
|
|
|
poster={getAssetUrl(data.video.image, "preview")}
|
2025-10-25 22:04:41 +02:00
|
|
|
autoplay
|
2025-10-28 10:31:06 +01:00
|
|
|
ontimeupdate={handleTimeUpdate}
|
2026-03-04 21:41:07 +01:00
|
|
|
class="block w-full"
|
2025-10-25 22:04:41 +02:00
|
|
|
>
|
|
|
|
|
<track kind="captions" />
|
|
|
|
|
</video>
|
|
|
|
|
<media-control-bar>
|
|
|
|
|
<media-play-button></media-play-button>
|
|
|
|
|
<media-mute-button></media-mute-button>
|
|
|
|
|
<media-volume-range></media-volume-range>
|
|
|
|
|
<media-time-range></media-time-range>
|
|
|
|
|
<media-pip-button></media-pip-button>
|
|
|
|
|
<media-fullscreen-button></media-fullscreen-button>
|
|
|
|
|
</media-control-bar>
|
|
|
|
|
</media-controller>
|
|
|
|
|
{:else}
|
|
|
|
|
<img
|
2026-03-04 22:27:54 +01:00
|
|
|
src={getAssetUrl(data.video.image, "medium")}
|
2025-10-25 22:04:41 +02:00
|
|
|
alt={data.video.title}
|
|
|
|
|
class="w-full h-full object-cover"
|
|
|
|
|
/>
|
2026-03-04 22:27:54 +01:00
|
|
|
<div class="absolute inset-0 bg-black/20 flex items-center justify-center">
|
2025-10-25 22:04:41 +02:00
|
|
|
<button
|
|
|
|
|
class="cursor-pointer w-20 h-20 bg-primary/90 hover:bg-primary rounded-full flex flex-col items-center justify-center transition-colors shadow-2xl"
|
|
|
|
|
aria-label={data.video.title}
|
|
|
|
|
data-umami-event="play-video"
|
|
|
|
|
data-umami-event-title={data.video.title}
|
2026-03-04 21:27:06 +01:00
|
|
|
data-umami-event-id={data.video.movie}
|
2025-10-25 22:04:41 +02:00
|
|
|
onclick={() => (showPlayer = true)}
|
|
|
|
|
>
|
2026-03-04 22:27:54 +01:00
|
|
|
<span class="icon-[ri--play-large-fill] w-10 h-10 text-white"></span>
|
2025-10-25 22:04:41 +02:00
|
|
|
</button>
|
|
|
|
|
</div>
|
2025-10-28 10:31:06 +01:00
|
|
|
<button
|
|
|
|
|
class="cursor-pointer absolute inset-0 bg-black/20 flex items-center justify-center"
|
|
|
|
|
aria-label={data.video.title}
|
|
|
|
|
data-umami-event="play-video"
|
|
|
|
|
data-umami-event-title={data.video.title}
|
2026-03-04 21:27:06 +01:00
|
|
|
data-umami-event-id={data.video.movie}
|
2025-10-28 10:31:06 +01:00
|
|
|
onclick={handlePlay}
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
class="w-20 h-20 bg-primary/90 hover:bg-primary rounded-full flex flex-col items-center justify-center transition-colors shadow-2xl"
|
|
|
|
|
>
|
2026-03-04 22:27:54 +01:00
|
|
|
<span class="icon-[ri--play-large-fill] w-10 h-10 text-white"></span>
|
2025-10-28 10:31:06 +01:00
|
|
|
</div>
|
|
|
|
|
</button>
|
2025-10-25 22:04:41 +02:00
|
|
|
<div
|
|
|
|
|
class="absolute bottom-4 left-4 bg-black/70 text-white px-3 py-1 rounded font-medium"
|
|
|
|
|
>
|
2026-03-04 22:27:54 +01:00
|
|
|
{#if data.video.movie_file?.duration}{formatVideoDuration(
|
|
|
|
|
data.video.movie_file.duration,
|
|
|
|
|
)}{/if}
|
2025-10-25 22:04:41 +02:00
|
|
|
</div>
|
|
|
|
|
{#if data.video.premium}
|
|
|
|
|
<div
|
|
|
|
|
class="absolute top-4 left-4 bg-gradient-to-r from-primary to-accent text-white px-3 py-1 rounded-full font-medium"
|
|
|
|
|
>
|
2026-03-04 22:27:54 +01:00
|
|
|
{$_("videos.premium")}
|
2025-10-25 22:04:41 +02:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
<!-- Video Info -->
|
|
|
|
|
<div class="space-y-4">
|
|
|
|
|
<div>
|
|
|
|
|
<h1 class="text-2xl md:text-3xl font-bold mb-2">
|
|
|
|
|
{data.video.title}
|
|
|
|
|
</h1>
|
2026-03-04 22:27:54 +01:00
|
|
|
<div class="flex flex-wrap items-center gap-4 text-sm text-muted-foreground">
|
2025-11-20 19:23:36 +01:00
|
|
|
{#if data.video.plays_count}
|
|
|
|
|
<div class="flex items-center gap-1">
|
|
|
|
|
<span class="icon-[ri--play-fill] w-4 h-4"></span>
|
2026-03-04 22:27:54 +01:00
|
|
|
{data.video.plays_count}
|
|
|
|
|
{data.video.plays_count === 1 ? "play" : "plays"}
|
2025-11-20 19:23:36 +01:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
2025-10-25 22:04:41 +02:00
|
|
|
<div class="flex items-center gap-1">
|
|
|
|
|
<span class="icon-[ri--calendar-line] w-4 h-4"></span>
|
|
|
|
|
{timeAgo.format(new Date(data.video.upload_date))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Action Buttons -->
|
|
|
|
|
<div class="flex flex-wrap gap-3">
|
2025-10-28 10:31:06 +01:00
|
|
|
<Button
|
2025-10-25 22:04:41 +02:00
|
|
|
variant={isLiked ? "default" : "outline"}
|
|
|
|
|
onclick={handleLike}
|
2025-10-28 10:31:06 +01:00
|
|
|
disabled={isLikeLoading}
|
|
|
|
|
class="flex items-center gap-2 cursor-pointer {isLiked
|
2025-10-25 22:04:41 +02:00
|
|
|
? 'bg-gradient-to-r from-primary to-accent'
|
|
|
|
|
: 'border-primary/20 hover:bg-primary/10'}"
|
|
|
|
|
>
|
2025-10-28 10:31:06 +01:00
|
|
|
<span class="icon-[ri--heart-{isLiked ? 'fill' : 'line'}] w-4 h-4"></span>
|
|
|
|
|
{likesCount}
|
|
|
|
|
</Button>
|
2025-10-25 22:04:41 +02:00
|
|
|
<SharingPopupButton
|
|
|
|
|
content={{
|
|
|
|
|
title: data.video.title,
|
|
|
|
|
description: data.video.description,
|
|
|
|
|
url: page.url.href,
|
2026-03-04 22:27:54 +01:00
|
|
|
type: "video" as const,
|
2025-10-25 22:04:41 +02:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Model Info -->
|
|
|
|
|
<div class="grid grid-cols-1 gap-4">
|
2026-03-04 22:24:55 +01:00
|
|
|
{#each data.video.models as model (model.slug)}
|
2025-10-25 22:04:41 +02:00
|
|
|
<div class="flex items-center justify-between">
|
|
|
|
|
<div class="flex items-center gap-4">
|
|
|
|
|
<a href={`/models/${model.slug}`}>
|
|
|
|
|
<img
|
2026-03-04 22:27:54 +01:00
|
|
|
src={getAssetUrl(model.avatar as string, "thumbnail")}
|
2025-10-25 22:04:41 +02:00
|
|
|
alt={model.artist_name}
|
|
|
|
|
class="w-12 h-12 rounded-full object-cover ring-2 ring-primary/20 hover:ring-primary/40 transition-all"
|
|
|
|
|
/>
|
|
|
|
|
</a>
|
|
|
|
|
<div>
|
|
|
|
|
<a
|
|
|
|
|
href={`/models/${model.slug}`}
|
|
|
|
|
class="font-semibold hover:text-primary transition-colors flex items-center gap-2"
|
|
|
|
|
>
|
|
|
|
|
{model.artist_name}
|
2026-03-04 22:27:54 +01:00
|
|
|
<div class="w-4 h-4 bg-primary rounded-full flex items-center justify-center">
|
|
|
|
|
<svg class="w-2.5 h-2.5 text-white" fill="currentColor" viewBox="0 0 20 20">
|
2025-10-25 22:04:41 +02:00
|
|
|
<path
|
|
|
|
|
fill-rule="evenodd"
|
|
|
|
|
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
|
|
|
|
|
clip-rule="evenodd"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
</div>
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Description -->
|
|
|
|
|
<Card class="p-0 bg-card/50">
|
|
|
|
|
<CardContent class="p-4">
|
|
|
|
|
<p class="text-muted-foreground mb-4">{data.video.description}</p>
|
|
|
|
|
<div class="flex flex-wrap gap-2">
|
2026-03-04 22:24:55 +01:00
|
|
|
{#each data.video.tags as tag (tag)}
|
2025-10-25 22:04:41 +02:00
|
|
|
<a
|
|
|
|
|
class="text-xs bg-primary/10 text-primary px-2 py-1 rounded-full"
|
|
|
|
|
href="/tags/{tag}"
|
|
|
|
|
>
|
|
|
|
|
#{tag}
|
|
|
|
|
</a>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
<!-- Comments Section -->
|
|
|
|
|
<Card class="p-0 bg-card/50">
|
|
|
|
|
<CardContent class="p-4">
|
|
|
|
|
<div class="flex items-center justify-between mb-4">
|
|
|
|
|
<h3 class="font-semibold flex items-center gap-2">
|
|
|
|
|
<span class="icon-[ri--message-line] w-5 h-5"></span>
|
2026-03-04 22:27:54 +01:00
|
|
|
{$_("videos.comments", {
|
2025-10-25 22:04:41 +02:00
|
|
|
values: {
|
2026-03-04 22:27:54 +01:00
|
|
|
comments: data.comments.length,
|
|
|
|
|
},
|
2025-10-25 22:04:41 +02:00
|
|
|
})}
|
|
|
|
|
</h3>
|
|
|
|
|
{#if data.comments.length > 0}
|
|
|
|
|
<Button
|
|
|
|
|
variant="link"
|
|
|
|
|
size="sm"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
onclick={() => (showComments = !showComments)}
|
|
|
|
|
>
|
2026-03-04 22:27:54 +01:00
|
|
|
{showComments ? $_("videos.hide") : $_("videos.show")}
|
2025-10-25 22:04:41 +02:00
|
|
|
</Button>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Add Comment -->
|
|
|
|
|
{#if data.authStatus.authenticated}
|
|
|
|
|
<div class="flex gap-3 mb-6">
|
2026-03-04 22:27:54 +01:00
|
|
|
<Avatar class="h-8 w-8 ring-2 ring-accent/20 transition-all duration-200">
|
2025-10-25 22:04:41 +02:00
|
|
|
<AvatarImage
|
feat: add shared @sexy.pivoine.art/types package and fix type safety across frontend/backend
- Create packages/types with shared TypeScript domain model interfaces (User, Video, Model, Article, Comment, Recording, etc.)
- Wire both frontend and backend packages to use @sexy.pivoine.art/types via workspace:*
- Update backend Pothos objectRef types to use shared interfaces instead of inline types
- Update frontend $lib/types.ts to re-export from shared package
- Fix all type errors introduced by more accurate nullable types (avatar/banner as string|null UUIDs, author nullable, events/device_info as object[])
- Add artist_name to comment user select in backend resolver
- Widen utility function signatures (getAssetUrl, getUserInitials, calcReadingTime) to accept null/undefined
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 11:01:11 +01:00
|
|
|
src={getAssetUrl(data.authStatus.user!.avatar, "mini")}
|
2025-10-25 22:04:41 +02:00
|
|
|
alt={data.authStatus.user!.artist_name}
|
|
|
|
|
/>
|
|
|
|
|
<AvatarFallback
|
|
|
|
|
class="bg-gradient-to-br from-primary to-accent text-primary-foreground text-xs font-semibold transition-all duration-200"
|
|
|
|
|
>
|
|
|
|
|
{getUserInitials(data.authStatus.user!.artist_name)}
|
|
|
|
|
</AvatarFallback>
|
|
|
|
|
</Avatar>
|
|
|
|
|
<form class="flex-1 space-y-4" onsubmit={handleComment}>
|
|
|
|
|
<div class="space-y-2">
|
|
|
|
|
<Textarea
|
2026-03-04 22:27:54 +01:00
|
|
|
placeholder={$_("videos.add_comment_placeholder")}
|
2025-10-25 22:04:41 +02:00
|
|
|
bind:value={newComment}
|
|
|
|
|
class="bg-background/50 border-primary/20 focus:border-primary resize-none"
|
|
|
|
|
rows={2}
|
|
|
|
|
></Textarea>
|
|
|
|
|
</div>
|
|
|
|
|
{#if isCommentError}
|
|
|
|
|
<div class="grid w-full max-w-xl items-start gap-4">
|
|
|
|
|
<Alert.Root variant="destructive">
|
|
|
|
|
<Alert.Title class="items-center flex"
|
2026-03-04 22:27:54 +01:00
|
|
|
><span class="icon-[ri--alert-line] inline-block w-4 h-4 mr-1"
|
|
|
|
|
></span>{$_("videos.error")}</Alert.Title
|
2025-10-25 22:04:41 +02:00
|
|
|
>
|
|
|
|
|
<Alert.Description>{commentError}</Alert.Description>
|
|
|
|
|
</Alert.Root>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
<div class="flex justify-end space">
|
|
|
|
|
<Button
|
|
|
|
|
size="sm"
|
|
|
|
|
class="cursor-pointer bg-gradient-to-r from-primary to-accent hover:from-primary/90 hover:to-accent/90"
|
|
|
|
|
disabled={!newComment.trim() || isCommentLoading}
|
|
|
|
|
type="submit"
|
|
|
|
|
>
|
|
|
|
|
{#if isCommentLoading}
|
|
|
|
|
<div
|
|
|
|
|
class="w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin mr-2"
|
|
|
|
|
></div>
|
2026-03-04 22:27:54 +01:00
|
|
|
{$_("videos.commenting")}
|
2025-10-25 22:04:41 +02:00
|
|
|
{:else}
|
2026-03-04 22:27:54 +01:00
|
|
|
{$_("videos.comment")}
|
2025-10-25 22:04:41 +02:00
|
|
|
{/if}
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
{#if showComments}
|
|
|
|
|
<!-- Comments List -->
|
|
|
|
|
<div class="space-y-4">
|
2026-03-04 22:24:55 +01:00
|
|
|
{#each data.comments as comment (comment.id)}
|
2025-10-25 22:04:41 +02:00
|
|
|
<div class="flex gap-3">
|
feat: add shared @sexy.pivoine.art/types package and fix type safety across frontend/backend
- Create packages/types with shared TypeScript domain model interfaces (User, Video, Model, Article, Comment, Recording, etc.)
- Wire both frontend and backend packages to use @sexy.pivoine.art/types via workspace:*
- Update backend Pothos objectRef types to use shared interfaces instead of inline types
- Update frontend $lib/types.ts to re-export from shared package
- Fix all type errors introduced by more accurate nullable types (avatar/banner as string|null UUIDs, author nullable, events/device_info as object[])
- Add artist_name to comment user select in backend resolver
- Widen utility function signatures (getAssetUrl, getUserInitials, calcReadingTime) to accept null/undefined
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 11:01:11 +01:00
|
|
|
<a href="/users/{comment.user?.id}" class="flex-shrink-0">
|
2025-10-28 12:54:45 +01:00
|
|
|
<Avatar
|
|
|
|
|
class="h-8 w-8 ring-2 ring-accent/20 hover:ring-primary/40 transition-all duration-200 cursor-pointer"
|
2025-10-25 22:04:41 +02:00
|
|
|
>
|
2025-10-28 12:54:45 +01:00
|
|
|
<AvatarImage
|
feat: add shared @sexy.pivoine.art/types package and fix type safety across frontend/backend
- Create packages/types with shared TypeScript domain model interfaces (User, Video, Model, Article, Comment, Recording, etc.)
- Wire both frontend and backend packages to use @sexy.pivoine.art/types via workspace:*
- Update backend Pothos objectRef types to use shared interfaces instead of inline types
- Update frontend $lib/types.ts to re-export from shared package
- Fix all type errors introduced by more accurate nullable types (avatar/banner as string|null UUIDs, author nullable, events/device_info as object[])
- Add artist_name to comment user select in backend resolver
- Widen utility function signatures (getAssetUrl, getUserInitials, calcReadingTime) to accept null/undefined
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 11:01:11 +01:00
|
|
|
src={getAssetUrl(comment.user?.avatar, "mini")}
|
|
|
|
|
alt={comment.user?.artist_name}
|
2025-10-28 12:54:45 +01:00
|
|
|
/>
|
|
|
|
|
<AvatarFallback
|
|
|
|
|
class="bg-gradient-to-br from-primary to-accent text-primary-foreground text-xs font-semibold transition-all duration-200"
|
|
|
|
|
>
|
feat: add shared @sexy.pivoine.art/types package and fix type safety across frontend/backend
- Create packages/types with shared TypeScript domain model interfaces (User, Video, Model, Article, Comment, Recording, etc.)
- Wire both frontend and backend packages to use @sexy.pivoine.art/types via workspace:*
- Update backend Pothos objectRef types to use shared interfaces instead of inline types
- Update frontend $lib/types.ts to re-export from shared package
- Fix all type errors introduced by more accurate nullable types (avatar/banner as string|null UUIDs, author nullable, events/device_info as object[])
- Add artist_name to comment user select in backend resolver
- Widen utility function signatures (getAssetUrl, getUserInitials, calcReadingTime) to accept null/undefined
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 11:01:11 +01:00
|
|
|
{getUserInitials(comment.user?.artist_name)}
|
2025-10-28 12:54:45 +01:00
|
|
|
</AvatarFallback>
|
|
|
|
|
</Avatar>
|
|
|
|
|
</a>
|
2025-10-25 22:04:41 +02:00
|
|
|
<div class="flex-1">
|
2026-03-07 19:37:52 +01:00
|
|
|
<div class="flex items-center mb-1">
|
2026-03-04 22:27:54 +01:00
|
|
|
<a
|
feat: add shared @sexy.pivoine.art/types package and fix type safety across frontend/backend
- Create packages/types with shared TypeScript domain model interfaces (User, Video, Model, Article, Comment, Recording, etc.)
- Wire both frontend and backend packages to use @sexy.pivoine.art/types via workspace:*
- Update backend Pothos objectRef types to use shared interfaces instead of inline types
- Update frontend $lib/types.ts to re-export from shared package
- Fix all type errors introduced by more accurate nullable types (avatar/banner as string|null UUIDs, author nullable, events/device_info as object[])
- Add artist_name to comment user select in backend resolver
- Widen utility function signatures (getAssetUrl, getUserInitials, calcReadingTime) to accept null/undefined
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 11:01:11 +01:00
|
|
|
href="/users/{comment.user?.id}"
|
2026-03-04 22:27:54 +01:00
|
|
|
class="font-medium text-sm hover:text-primary transition-colors"
|
feat: add shared @sexy.pivoine.art/types package and fix type safety across frontend/backend
- Create packages/types with shared TypeScript domain model interfaces (User, Video, Model, Article, Comment, Recording, etc.)
- Wire both frontend and backend packages to use @sexy.pivoine.art/types via workspace:*
- Update backend Pothos objectRef types to use shared interfaces instead of inline types
- Update frontend $lib/types.ts to re-export from shared package
- Fix all type errors introduced by more accurate nullable types (avatar/banner as string|null UUIDs, author nullable, events/device_info as object[])
- Add artist_name to comment user select in backend resolver
- Widen utility function signatures (getAssetUrl, getUserInitials, calcReadingTime) to accept null/undefined
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 11:01:11 +01:00
|
|
|
>{comment.user?.artist_name}</a
|
2025-10-25 22:04:41 +02:00
|
|
|
>
|
|
|
|
|
<span class="text-xs text-muted-foreground"
|
2026-03-04 22:27:54 +01:00
|
|
|
>{timeAgo.format(new Date(comment.date_created))}</span
|
2025-10-25 22:04:41 +02:00
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
<p class="text-sm mb-2">{comment.comment}</p>
|
2026-03-07 11:19:50 +01:00
|
|
|
{#if data.authStatus.user?.id === comment.user_id || data.authStatus.user?.is_admin}
|
|
|
|
|
<button
|
|
|
|
|
class="text-xs text-muted-foreground hover:text-destructive transition-colors"
|
|
|
|
|
onclick={() => handleDeleteComment(comment.id)}
|
2025-10-25 22:04:41 +02:00
|
|
|
>
|
2026-03-07 11:19:50 +01:00
|
|
|
{$_("common.delete")}
|
|
|
|
|
</button>
|
|
|
|
|
{/if}
|
2025-10-25 22:04:41 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Sidebar -->
|
|
|
|
|
<div class="space-y-6">
|
|
|
|
|
<!-- Related Videos -->
|
|
|
|
|
<!-- <Card class="bg-card/50">
|
|
|
|
|
<CardContent class="p-4">
|
|
|
|
|
<h3 class="font-semibold mb-4">Related Videos</h3>
|
|
|
|
|
<div class="space-y-4">
|
|
|
|
|
{#each relatedVideos as relatedVideo}
|
|
|
|
|
<button
|
|
|
|
|
onclick={() => onNavigate('video')}
|
|
|
|
|
class="flex gap-3 w-full text-left hover:bg-primary/5 p-2 rounded-lg transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<div class="relative">
|
|
|
|
|
<img
|
|
|
|
|
src={relatedData.video.thumbnail}
|
|
|
|
|
alt={relatedData.video.title}
|
|
|
|
|
class="w-24 h-16 object-cover rounded"
|
|
|
|
|
/>
|
|
|
|
|
<div
|
|
|
|
|
class="absolute bottom-1 right-1 bg-black/70 text-white text-xs px-1 rounded"
|
|
|
|
|
>
|
|
|
|
|
{relatedData.video.duration}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex-1 min-w-0">
|
|
|
|
|
<h4 class="font-medium text-sm line-clamp-2 mb-1">
|
|
|
|
|
{relatedData.video.title}
|
|
|
|
|
</h4>
|
|
|
|
|
<p class="text-xs text-muted-foreground">
|
|
|
|
|
{relatedData.video.model}
|
|
|
|
|
</p>
|
|
|
|
|
<p class="text-xs text-muted-foreground">
|
|
|
|
|
{relatedData.video.views} views
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card> -->
|
|
|
|
|
|
|
|
|
|
<!-- Back to Videos -->
|
|
|
|
|
<Button
|
|
|
|
|
variant="outline"
|
|
|
|
|
href="/videos"
|
|
|
|
|
class="w-full border-primary/20 hover:bg-primary/10"
|
2026-03-04 22:27:54 +01:00
|
|
|
><span class="icon-[ri--arrow-left-long-line] w-4 h-4 mr-1"></span>{$_(
|
|
|
|
|
"videos.back",
|
|
|
|
|
)}</Button
|
2025-10-25 22:04:41 +02:00
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|