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() {
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<FlatList<DecryptedMessage>>(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) => {