From cb7bd99fb4e6383e7e097a80647bd22acab76a59 Mon Sep 17 00:00:00 2001 From: byGalax Date: Sat, 16 May 2026 17:13:47 +0200 Subject: [PATCH] refactor(mobile): conversation detail uses ownUserId + drops senderDeviceId --- apps/mobile/app/(app)/conversations/[id].tsx | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/apps/mobile/app/(app)/conversations/[id].tsx b/apps/mobile/app/(app)/conversations/[id].tsx index 31e2de2..1759bc6 100644 --- a/apps/mobile/app/(app)/conversations/[id].tsx +++ b/apps/mobile/app/(app)/conversations/[id].tsx @@ -30,7 +30,7 @@ import { colors } from '../../../theme/colors'; export default function ConversationDetail() { const { id } = useLocalSearchParams<{ id: string }>(); - const { user, device, ownPrivateKey } = useAuth(); + const { user, userId, ownPrivateKey } = useAuth(); const { state: callState, startCall } = useCall(); const router = useRouter(); @@ -54,7 +54,7 @@ export default function ConversationDetail() { const listRef = useRef>(null); const load = useCallback(async () => { - if (!id || !device || !ownPrivateKey) return; + if (!id || !userId || !ownPrivateKey) return; setError(null); try { const all = await chat.listConversations(supabase); @@ -63,7 +63,7 @@ export default function ConversationDetail() { const decrypted = await chat.decryptMessages({ client: supabase, messages: ciphers, - ownDeviceId: device.id, + ownUserId: userId, ownPrivateKey, }); setMessages(decrypted); @@ -81,7 +81,7 @@ export default function ConversationDetail() { } catch (err: unknown) { setError(err instanceof Error ? err.message : 'Nachrichten konnten nicht geladen werden'); } - }, [id, device, ownPrivateKey]); + }, [id, userId, ownPrivateKey]); useEffect(() => { void load(); @@ -103,7 +103,7 @@ export default function ConversationDetail() { : (conversation?.peer?.displayName ?? '…'); async function handleSendText() { - if (!text.trim() || !user || !device || !ownPrivateKey || !id || sending) return; + if (!text.trim() || !user || !ownPrivateKey || !id || sending) return; setSending(true); setError(null); const replyToId = replyTo?.id; @@ -113,7 +113,6 @@ export default function ConversationDetail() { conversationId: id, plaintext: text.trim(), senderUserId: user.id, - senderDeviceId: device.id, senderPrivateKey: ownPrivateKey, ...(replyToId ? { replyToId } : {}), }); @@ -128,7 +127,7 @@ export default function ConversationDetail() { } async function sendImage(pick: PickedImage) { - if (!user || !device || !ownPrivateKey || !id) return; + if (!user || !ownPrivateKey || !id) return; setSending(true); setError(null); try { @@ -148,7 +147,6 @@ export default function ConversationDetail() { conversationId: id, plaintext: '', senderUserId: user.id, - senderDeviceId: device.id, senderPrivateKey: ownPrivateKey, attachmentHandles: [result.handle], }); @@ -300,7 +298,6 @@ export default function ConversationDetail() { })} reactions={reactions.get(item.id) ?? []} myUserId={user?.id ?? null} - ownDeviceId={device?.id ?? null} ownPrivateKey={ownPrivateKey} onLongPress={() => setActiveMessage(item)} onToggleReaction={(emoji) => {