Phase 9c: Inbox-Banner auf /decks und /study

InboxBanner.svelte zeigt einen klickbaren Hinweis, wenn der User
ein Inbox-Deck hat und es Karten enthält. Linkt aufs Inbox-Deck,
wo die Karten in andere Decks umsortiert werden können.

API-Pfad bleibt schmal: kein neuer Endpunkt — die Komponente
nutzt listDecks() + listCards(inbox.id) und filtert clientseitig
auf name === "Inbox" (der stabile API-Konstantenname). Wenn das
später Hot-Path wird, ist GET /api/v1/inbox/stats ein additiver
Fix.

svelte-check 356 files 0 errors.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-05-08 17:54:19 +02:00
parent 35366ed4f2
commit 47419b3cac
4 changed files with 63 additions and 0 deletions

View file

@ -0,0 +1,23 @@
import type { Deck } from '@cards/domain';
import { listDecks } from './decks.ts';
import { listCards } from './cards.ts';
const INBOX_NAME = 'Inbox';
export interface InboxStats {
deck: Deck | null;
cardCount: number;
}
/**
* Lädt das Inbox-Deck (Name = "Inbox", auto-erzeugt vom API beim
* ersten Share-Receive) und zählt die Karten darin. Liefert ein
* neutrales Result, wenn der User noch keinen Share empfangen hat.
*/
export async function loadInboxStats(): Promise<InboxStats> {
const decks = await listDecks();
const inbox = decks.decks.find((d) => d.name === INBOX_NAME) ?? null;
if (!inbox) return { deck: null, cardCount: 0 };
const cards = await listCards(inbox.id);
return { deck: inbox, cardCount: cards.total };
}