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>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { useEffect } from 'react';
|
|
import { AppState, type AppStateStatus } from 'react-native';
|
|
import { apiFetch } from '../lib/api';
|
|
|
|
const ping = (reason: string) => {
|
|
apiFetch('/api/me/last-seen', { method: 'POST' })
|
|
.then((r) => console.log('[presence] heartbeat OK (' + reason + ')', r))
|
|
.catch((e) => console.warn('[presence] heartbeat FAIL (' + reason + '):', e?.message ?? e));
|
|
};
|
|
|
|
export function useLastSeenHeartbeat(enabled: boolean) {
|
|
useEffect(() => {
|
|
if (!enabled) return;
|
|
|
|
// 60s-Interval während App im Foreground
|
|
const interval = setInterval(() => {
|
|
if (AppState.currentState === 'active') {
|
|
ping('interval');
|
|
}
|
|
}, 60_000);
|
|
|
|
// Phase-2-Alternative zur Edge-Function: bei App-Background sofort einen
|
|
// finalen Ping → lastSeenAt ist exakt der Schließ-Zeitpunkt, kein 60s-Lag
|
|
// mehr für den letzten-aktiv-Zustand. 90% Edge-Function-Gewinn ohne Setup.
|
|
const sub = AppState.addEventListener('change', (next: AppStateStatus) => {
|
|
if (next === 'background' || next === 'inactive') {
|
|
ping('background');
|
|
}
|
|
});
|
|
|
|
return () => {
|
|
clearInterval(interval);
|
|
sub.remove();
|
|
};
|
|
}, [enabled]);
|
|
}
|