Sync shared snapshot from 43d77dd
Docker / Docker Build & Push (push) Successful in 3m34s

This commit is contained in:
Gabriel20xx committed 2026-09-01 08:44:09 +02:00
1 parent 9a6ec940f7
commit fd32419371
114 files changed
+21997 -96

No files matched your search

@@ -0,0 +1,116 @@
<script lang="ts">
import { page } from '$app/state'
import { Film, Music2, Play } from '@lucide/svelte'
import { get } from '$lib/api'
import EmptyState from '$lib/components/EmptyState.svelte'
import Badge from '$lib/components/ui/badge.svelte'
import Button from '$lib/components/ui/button.svelte'
import Card from '$lib/components/ui/card.svelte'
interface FeedItem {
mediaKey?: string
url?: string
thumbnail?: string
name?: string
filename?: string
mediaType?: string
title?: string | null
category?: string | null
}
let item = $state<FeedItem | null>(null)
let loading = $state(true)
let error = $state('')
let reloadToken = $state(0)
let loadSequence = 0
const exactMedia = $derived(page.url.searchParams.get('video')?.trim() || '')
async function loadFeed(exact: string) {
const sequence = ++loadSequence
loading = true
error = ''
try {
const query = exact ? `?exact=${encodeURIComponent(exact)}` : ''
const response = await get<{ data?: FeedItem }>(`/api/media/random/all${query}`)
if (sequence !== loadSequence) return
item = response.data || null
if (!item) error = 'No media found.'
} catch (reason) {
if (sequence !== loadSequence) return
item = null
error = reason instanceof Error ? reason.message : 'Unable to load the media feed.'
} finally {
if (sequence === loadSequence) loading = false
}
}
$effect(() => {
const exact = exactMedia
const token = reloadToken
void token
void loadFeed(exact)
})
function nextItem() {
if (exactMedia) window.location.href = '/feed'
else reloadToken += 1
}
function isImage(media: FeedItem) {
return media.mediaType === 'static' || media.mediaType === 'image'
}
</script>
<div>
{#if loading}
<div class="media-shimmer mx-auto h-[min(70dvh,48rem)] max-w-4xl rounded-xl border border-border"></div>
{:else if error}
<div class="rounded-md border border-danger/30 bg-danger/10 px-4 py-3 text-sm text-danger">{error}</div>
{:else if !item}
<EmptyState title="No media found" message="The feed will appear once media has been indexed." />
{:else}
<Card class="mx-auto max-w-4xl overflow-hidden p-0">
<div class="relative flex min-h-[min(70dvh,48rem)] items-center justify-center overflow-hidden bg-black">
{#if isImage(item)}
<img
src={item.url || item.thumbnail || ''}
alt={item.title || item.name || item.filename || 'Media'}
class="max-h-[min(70dvh,48rem)] max-w-full object-contain"
/>
{:else if item.url}
<video
src={item.url}
poster={item.thumbnail}
controls
autoplay
playsinline
class="max-h-[min(70dvh,48rem)] max-w-full object-contain"
>
<track kind="captions" srclang="en" label="Captions" src="data:text/vtt,WEBVTT" />
</video>
{:else}
<div class="flex flex-col items-center gap-3 text-muted-fg">
{#if item.mediaType === 'audio'}<Music2 class="size-12" />{:else}<Film class="size-12" />{/if}
<span>Preview unavailable</span>
</div>
{/if}
</div>
<div class="flex flex-col gap-3 border-t border-border p-4 sm:flex-row sm:items-center sm:justify-between">
<div class="min-w-0">
<p class="truncate text-sm font-medium text-fg">
{item.title || item.name || item.filename || 'Untitled media'}
</p>
<div class="mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-fg">
{#if item.mediaType}<Badge tone="neutral">{item.mediaType}</Badge>{/if}
{#if item.category}<span>{item.category}</span>{/if}
{#if item.filename}<span class="truncate">{item.filename}</span>{/if}
</div>
</div>
<Button size="sm" onclick={() => void nextItem()} disabled={loading}><Play />Next item</Button>
</div>
</Card>
{/if}
</div>