import React, { useEffect, useState } from 'react'; import { Loader2, RotateCcw, Trash2 } from 'lucide-react'; import { api, triggerHaptic } from '../../lib/api'; import { formatDeletedAt } from '../../lib/due'; import type { Thought } from '../../lib/types'; import { ReadingModal } from '../../components/ReadingModal'; interface TriageTrashProps { onClose: () => void; // Something was restored or deleted: counters and the deck change onChanged: () => void; } // The triage's own trash: thoughts thrown away while sorting. Back into the Quick Dump, or deleted for // good (one by one, all at once, or after the delay from Kontoeinstellungen → Aufbewahrung). Deleting // for good takes a second tap on the same button, like the notes trash. export const TriageTrash: React.FC = ({ onClose, onChanged }) => { const [items, setItems] = useState(null); const [confirmId, setConfirmId] = useState(null); const load = async () => { const list = await api.getThoughts('discarded').catch(() => []); setItems(Array.isArray(list) ? list : []); }; useEffect(() => { void load(); }, []); const restore = async (item: Thought) => { triggerHaptic(15); await api.triageAction(item.id, 'restore'); await load(); onChanged(); }; const purge = async (id: string) => { if (confirmId !== id) { setConfirmId(id); return; } triggerHaptic(20); setConfirmId(null); if (id === '__all__') await api.purgeDiscarded(); else await api.deleteThought(id); await load(); onChanged(); }; return ( {items === null ? (
) : items.length === 0 ? (

Keine verworfenen Gedanken.

) : (
{items.map((item) => (

{item.content}

{item.triagedAt &&

verworfen {formatDeletedAt(item.triagedAt)}

}
))}
)}
); };