Mail-Page-Refactor — Privacy-friendly + DiGA-tauglich:
- Custom title pro mail-connection (z.B. "Privat-Gmail" statt voller E-Mail).
Memory-Pattern: Anonymität via Nickname jetzt auch für Mail-Adressen
sichtbar, Datenminimierung. Title nullable, Fallback auf Email-Domain.
- Schema-Migration mail_connection_title (additiv, NULL default für Bestand)
- Endpoint PATCH /api/mail-connections/:id mit title-Validation (max 60,
trim, leerer String → NULL)
- "Passwort ändern"-Collapsible → vollwertige "Einstellungen"-Sektion:
Title editieren · Email read-only · Passwort neu setzen · Verbindung
trennen (mit Confirm-Dialog)
- EditMailTitleSheet als FormSheet-Pattern für Title-Edit
- mailConnectDraft-Store kriegt Title-Feld für Pre-Fill bei Re-Open
Zwei neue Stats-Charts auf der Mail-Page:
- MailBlockedByDayChart — 30-Tage-Bar-Chart, Plain-View-Bars (Pattern wie
Sparkline-Profile), Empty-State bei 0 Cooldowns
· Backend: GET /api/mail/stats/blocked-by-day?days=30
- MailDistributionChart — Half-Donut via react-native-svg, Top-5 Connections
+ "Sonstige", rendert nicht bei ≤1 Connection
· Backend: GET /api/mail/stats/blocked-by-connection
Activity-Log mit Provider-Filter:
- Filter-Chips Mo Gmail/Outlook/iCloud/etc. über bestehendem Activity-Log
- GET /api/mail/results?provider=X (war vorher hardcoded all)
- Endpoint-Naming-Fix in useMailResults (war /api/mail/blocked, jetzt
korrekt /api/mail/results — UI-Agent hatte falschen Path geraten)
Backend-Side-Effects:
- imap-providers util resolveProviderMeta(host) — gibt {provider, label,
isCustomDomain} zurück, von 3 Endpoints konsumiert
- /api/mail/status erweitert: title, provider, providerLabel,
isCustomDomain im Account-Shape
- /api/mail/results erweitert: connection-Sub-Objekt pro Entry +
provider-Filter-Query
Open follow-ups (TODOs):
- deleteOldMailBlocked-Cron löscht <24h → Bar-Chart-Daten weg. Retention
auf 90 Tage hochsetzen oder Cron stoppen.
- POST /api/mail/connect könnte die neue connection.id im Response
mitliefern → Title-PATCH direkt ohne Extra-GET (UI-Agent-Empfehlung).
- /api/mail/status zeigt nur active Connections — paused mit Title wären
unsichtbar. Entscheiden.
18 neue i18n-Keys (mail.title_*, mail.settings_*, mail.row_*,
mail.disconnect_confirm_*, mail.stats.*, mail.filter.all) in DE + EN.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { create } from 'zustand';
|
|
import type { MailProvider } from '../hooks/useMailConnect';
|
|
|
|
type ProviderSnapshot = {
|
|
id: MailProvider;
|
|
labelKey: string;
|
|
icon: string;
|
|
color: string;
|
|
guideKey: string;
|
|
guideUrl: string;
|
|
disabled?: boolean;
|
|
disabledLabelKey?: string;
|
|
};
|
|
|
|
type MailConnectDraftState = {
|
|
view: 'consent' | 'grid' | 'form';
|
|
consentGiven: boolean;
|
|
selectedProvider: ProviderSnapshot | null;
|
|
email: string;
|
|
title: string;
|
|
|
|
setView: (view: 'consent' | 'grid' | 'form') => void;
|
|
setConsentGiven: (v: boolean) => void;
|
|
setSelectedProvider: (p: ProviderSnapshot | null) => void;
|
|
setEmail: (email: string) => void;
|
|
setTitle: (title: string) => void;
|
|
reset: () => void;
|
|
};
|
|
|
|
const INITIAL: Pick<
|
|
MailConnectDraftState,
|
|
'view' | 'consentGiven' | 'selectedProvider' | 'email' | 'title'
|
|
> = {
|
|
view: 'consent',
|
|
consentGiven: false,
|
|
selectedProvider: null,
|
|
email: '',
|
|
title: '',
|
|
};
|
|
|
|
export const useMailConnectDraft = create<MailConnectDraftState>((set) => ({
|
|
...INITIAL,
|
|
|
|
setView: (view) => set({ view }),
|
|
setConsentGiven: (consentGiven) => set({ consentGiven }),
|
|
setSelectedProvider: (selectedProvider) => set({ selectedProvider }),
|
|
setEmail: (email) => set({ email }),
|
|
setTitle: (title) => set({ title }),
|
|
reset: () => set(INITIAL),
|
|
}));
|