refactor(mobile): conversation detail uses ownUserId + drops senderDeviceId

This commit is contained in:
byGalax
2026-05-16 17:13:47 +02:00
parent 3b55fcaf2c
commit cb7bd99fb4
+6 -9
View File
@@ -30,7 +30,7 @@ import { colors } from '../../../theme/colors';
export default function ConversationDetail() { export default function ConversationDetail() {
const { id } = useLocalSearchParams<{ id: string }>(); const { id } = useLocalSearchParams<{ id: string }>();
const { user, device, ownPrivateKey } = useAuth(); const { user, userId, ownPrivateKey } = useAuth();
const { state: callState, startCall } = useCall(); const { state: callState, startCall } = useCall();
const router = useRouter(); const router = useRouter();
@@ -54,7 +54,7 @@ export default function ConversationDetail() {
const listRef = useRef<FlatList<DecryptedMessage>>(null); const listRef = useRef<FlatList<DecryptedMessage>>(null);
const load = useCallback(async () => { const load = useCallback(async () => {
if (!id || !device || !ownPrivateKey) return; if (!id || !userId || !ownPrivateKey) return;
setError(null); setError(null);
try { try {
const all = await chat.listConversations(supabase); const all = await chat.listConversations(supabase);
@@ -63,7 +63,7 @@ export default function ConversationDetail() {
const decrypted = await chat.decryptMessages({ const decrypted = await chat.decryptMessages({
client: supabase, client: supabase,
messages: ciphers, messages: ciphers,
ownDeviceId: device.id, ownUserId: userId,
ownPrivateKey, ownPrivateKey,
}); });
setMessages(decrypted); setMessages(decrypted);
@@ -81,7 +81,7 @@ export default function ConversationDetail() {
} catch (err: unknown) { } catch (err: unknown) {
setError(err instanceof Error ? err.message : 'Nachrichten konnten nicht geladen werden'); setError(err instanceof Error ? err.message : 'Nachrichten konnten nicht geladen werden');
} }
}, [id, device, ownPrivateKey]); }, [id, userId, ownPrivateKey]);
useEffect(() => { useEffect(() => {
void load(); void load();
@@ -103,7 +103,7 @@ export default function ConversationDetail() {
: (conversation?.peer?.displayName ?? '…'); : (conversation?.peer?.displayName ?? '…');
async function handleSendText() { async function handleSendText() {
if (!text.trim() || !user || !device || !ownPrivateKey || !id || sending) return; if (!text.trim() || !user || !ownPrivateKey || !id || sending) return;
setSending(true); setSending(true);
setError(null); setError(null);
const replyToId = replyTo?.id; const replyToId = replyTo?.id;
@@ -113,7 +113,6 @@ export default function ConversationDetail() {
conversationId: id, conversationId: id,
plaintext: text.trim(), plaintext: text.trim(),
senderUserId: user.id, senderUserId: user.id,
senderDeviceId: device.id,
senderPrivateKey: ownPrivateKey, senderPrivateKey: ownPrivateKey,
...(replyToId ? { replyToId } : {}), ...(replyToId ? { replyToId } : {}),
}); });
@@ -128,7 +127,7 @@ export default function ConversationDetail() {
} }
async function sendImage(pick: PickedImage) { async function sendImage(pick: PickedImage) {
if (!user || !device || !ownPrivateKey || !id) return; if (!user || !ownPrivateKey || !id) return;
setSending(true); setSending(true);
setError(null); setError(null);
try { try {
@@ -148,7 +147,6 @@ export default function ConversationDetail() {
conversationId: id, conversationId: id,
plaintext: '', plaintext: '',
senderUserId: user.id, senderUserId: user.id,
senderDeviceId: device.id,
senderPrivateKey: ownPrivateKey, senderPrivateKey: ownPrivateKey,
attachmentHandles: [result.handle], attachmentHandles: [result.handle],
}); });
@@ -300,7 +298,6 @@ export default function ConversationDetail() {
})} })}
reactions={reactions.get(item.id) ?? []} reactions={reactions.get(item.id) ?? []}
myUserId={user?.id ?? null} myUserId={user?.id ?? null}
ownDeviceId={device?.id ?? null}
ownPrivateKey={ownPrivateKey} ownPrivateKey={ownPrivateKey}
onLongPress={() => setActiveMessage(item)} onLongPress={() => setActiveMessage(item)}
onToggleReaction={(emoji) => { onToggleReaction={(emoji) => {