Online-Status (Phase 1+):
- UserAvatar mit 4 Size-Variants (sm/md/lg/xl) + integrierter Online-Dot
- OnlinePresenceProvider: Supabase-Channel + Following-Filter
- ChatHeaderStatus: "Online" neutral / "vor X min" offline
- useLastSeen + Heartbeat (60s interval + AppState-background ping)
- Privatsphäre-Toggle in profile/index
Sheets:
- FormSheet Android-keyboard-fix (Dimensions.get('screen'), kein
useWindowDimensions-Kollaps), useKeyboardHandler statt manual
Keyboard.addListener, state-reset on re-open
- PostCommentsSheet same Pattern + close-after-submit + drag bis under
app-header
- ConnectMailSheet form-view refactor: scrollable, AES-Banner als
footnote, field-order email→pw→label, fixed 0.85 über alle Steps
Chat:
- DmChatBackground iOS klecks fix (G transform statt nested Svg)
- ChatInput Lyra-1:1 (keyboardWillShow, surfaceElevated bubble,
arrow-up send, attachment links)
- dm/room/chat headers + conversation-list nutzen UserAvatar
- Foreign-Profile "Nachricht"-Button öffnet richtige DM
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import { Text } from 'react-native';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useOnlineUsers } from '../../hooks/useOnlineUsers';
|
|
import { useLastSeenBatch } from '../../hooks/useLastSeenBatch';
|
|
|
|
type Props = {
|
|
userId: string;
|
|
};
|
|
|
|
function formatLastSeen(ts: string, t: (key: string, opts?: Record<string, unknown>) => string): string {
|
|
const diff = Date.now() - new Date(ts).getTime();
|
|
if (diff < 60_000) return t('presence.just_now');
|
|
if (diff < 3_600_000) return t('presence.minutes_ago', { minutes: Math.floor(diff / 60_000) });
|
|
if (diff < 86_400_000) return t('presence.hours_ago', { hours: Math.floor(diff / 3_600_000) });
|
|
return t('presence.days_ago', { days: Math.floor(diff / 86_400_000) });
|
|
}
|
|
|
|
export function ChatHeaderStatus({ userId }: Props) {
|
|
const { t } = useTranslation();
|
|
const { isOnline } = useOnlineUsers();
|
|
const lastSeenMap = useLastSeenBatch(isOnline(userId) ? [] : [userId]);
|
|
const online = isOnline(userId);
|
|
|
|
if (online) {
|
|
// User-Wunsch: „Online"-Text zeigen, aber NICHT grün (Dot im Avatar reicht
|
|
// als Farb-Signal). Neutraler `textMuted`-Grau-Ton.
|
|
return (
|
|
<Text style={{ fontSize: 12, fontFamily: 'Nunito_400Regular', color: '#a3a3a3' }}>
|
|
{t('presence.online')}
|
|
</Text>
|
|
);
|
|
}
|
|
|
|
const lastSeen = lastSeenMap[userId];
|
|
if (!lastSeen) return null;
|
|
|
|
return (
|
|
<Text style={{ fontSize: 12, fontFamily: 'Nunito_400Regular', color: '#a3a3a3' }}>
|
|
{formatLastSeen(lastSeen, t)}
|
|
</Text>
|
|
);
|
|
}
|