Chats: Zähler ungelesener Nachrichten am Chat-Symbol

Damit man neue Nachrichten bemerkt, ohne die Chats zu öffnen. Schlichtes
invertiertes Kästchen mit der Zahl, in TabBar und Seitenleiste; im aktiven
Ziel wieder umgekehrt. Die Zahl kommt aus derselben Abfrage wie die
Gesprächsübersicht (alle 30 s, nach dem Lesen sofort neu), also ohne
eigenen Endpunkt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TiXsPUqw7oeomZ8wZrQW5q
This commit is contained in:
irrlicht
2026-10-13 13:20:04 +02:00
co-authored by Claude Opus 5.5
parent f75407ea5b
commit c2fec2555a
6 changed files with 71 additions and 14 deletions
+2 -7
View File
@@ -9,6 +9,7 @@ import { submitOnShiftEnter } from "../keys";
import { unlockKeyring, useKeyring, type Keyring } from "../keyring";
import { decryptMessage, encryptMessage, formatFingerprint, ImportError, toBase64, type KeyInfo } from "../keystore";
import { useUserKey } from "../useKey";
import { useChats } from "../chats";
import type { Profile } from "../types";
// Direktnachrichten (notes/chats.md): Ende-zu-Ende verschlüsselt mit den
@@ -21,9 +22,7 @@ const retentionDays = 15;
// Form (pgpkey.MaxMessage).
const maxMessage = 4000;
const pollChat = 5_000;
const pollList = 30_000;
type ChatSummary = { username: string; avatar: string; last_at: number; unread: number };
type Message = { id: number; mine: boolean; body: string; created_at: number };
type Shown = { id: number; mine: boolean; created_at: number; text: string; verified: boolean; unreadable: boolean };
@@ -45,11 +44,7 @@ export function ChatsPage() {
function ChatList({ username }: { username: string }) {
const own = useUserKey(username);
const chats = useQuery({
queryKey: ["chats"],
queryFn: async () => (await api.get<{ chats: ChatSummary[] }>("/chats")).chats,
refetchInterval: pollList,
});
const chats = useChats();
return (
<>
<p className="muted">Nachrichten sind Ende-zu-Ende verschlüsselt und verschwinden nach {retentionDays} Tagen.</p>