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>
102 lines
2.5 KiB
TypeScript
102 lines
2.5 KiB
TypeScript
import { useState } from 'react';
|
|
import { ActivityIndicator, Text, TouchableOpacity, View } from 'react-native';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useMailTitleEdit } from '../../hooks/useMailTitleEdit';
|
|
import { FormSheet } from '../FormSheet';
|
|
import { SheetFieldStack } from '../SheetFieldStack';
|
|
|
|
type Props = {
|
|
visible: boolean;
|
|
connectionId: string;
|
|
currentTitle: string | null;
|
|
onClose: () => void;
|
|
onSuccess: (newTitle: string | null) => void;
|
|
};
|
|
|
|
export function EditMailTitleSheet({
|
|
visible,
|
|
connectionId,
|
|
currentTitle,
|
|
onClose,
|
|
onSuccess,
|
|
}: Props) {
|
|
const { t } = useTranslation();
|
|
const { saveTitle, saving, error } = useMailTitleEdit();
|
|
const [title, setTitle] = useState(currentTitle ?? '');
|
|
|
|
function handleClose() {
|
|
setTitle(currentTitle ?? '');
|
|
onClose();
|
|
}
|
|
|
|
async function handleSave() {
|
|
const ok = await saveTitle(connectionId, title);
|
|
if (ok) {
|
|
onSuccess(title.trim() || null);
|
|
onClose();
|
|
}
|
|
}
|
|
|
|
return (
|
|
<FormSheet
|
|
visible={visible}
|
|
onClose={handleClose}
|
|
title={t('mail.title_edit_title')}
|
|
initialHeightPct={0.45}
|
|
growWithKeyboard
|
|
>
|
|
<SheetFieldStack
|
|
fields={[
|
|
{
|
|
key: 'title',
|
|
label: t('mail.title_label'),
|
|
placeholder: t('mail.title_placeholder'),
|
|
value: title,
|
|
onChangeText: setTitle,
|
|
autoCapitalize: 'sentences',
|
|
autoCorrect: false,
|
|
},
|
|
]}
|
|
onComplete={() => {}}
|
|
>
|
|
{error && (
|
|
<Text
|
|
style={{
|
|
fontSize: 13,
|
|
fontFamily: 'Nunito_400Regular',
|
|
color: '#dc2626',
|
|
marginBottom: 10,
|
|
}}
|
|
>
|
|
{error}
|
|
</Text>
|
|
)}
|
|
|
|
<TouchableOpacity
|
|
activeOpacity={0.85}
|
|
onPress={handleSave}
|
|
disabled={saving}
|
|
style={{ marginTop: 4, marginBottom: 12 }}
|
|
>
|
|
<View
|
|
style={{
|
|
paddingVertical: 14,
|
|
borderRadius: 12,
|
|
backgroundColor: saving ? '#d4d4d4' : '#007AFF',
|
|
alignItems: 'center',
|
|
}}
|
|
>
|
|
{saving ? (
|
|
<ActivityIndicator color="#fff" />
|
|
) : (
|
|
<Text style={{ fontSize: 15, fontFamily: 'Nunito_700Bold', color: '#fff' }}>
|
|
{t('mail.title_save')}
|
|
</Text>
|
|
)}
|
|
</View>
|
|
</TouchableOpacity>
|
|
</SheetFieldStack>
|
|
</FormSheet>
|
|
);
|
|
}
|