Improve chat encryption, delivery, and session handling
Adds robust session serialization/deserialization for ratchet state, session cleanup for corrupted data, and improved error handling in chat encryption hooks. Enhances chat delivery to support both local and remote recipients, ensures conversation creation, and adds timeouts to key fetches. Also introduces utilities for deleting and clearing encrypted session data from storage.
This commit is contained in:
+10
-3
@@ -302,25 +302,32 @@ export default function ChatPage() {
|
||||
const data = await res.json();
|
||||
if (!data.user?.did) {
|
||||
alert('User not found or V2 not enabled.');
|
||||
setSending(false);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[Chat UI] Starting chat with:', data.user);
|
||||
|
||||
// Send "Hello" to init session
|
||||
await sendMessage(data.user.did, '👋', data.user.nodeDomain, data.user.handle);
|
||||
|
||||
console.log('[Chat UI] Message sent, reloading conversations');
|
||||
|
||||
setShowNewChat(false);
|
||||
setNewChatHandle('');
|
||||
loadConversations(false);
|
||||
await loadConversations(false);
|
||||
// Select the new conversation (we might need to find it)
|
||||
// For now just reload list.
|
||||
} catch (e: any) {
|
||||
console.error('Start chat failed:', e);
|
||||
console.error('[Chat UI] Start chat failed:', e);
|
||||
if (e.message.includes('Recipient keys not found')) {
|
||||
alert('This user has not set up secure chat yet. They need to log in to enable end-to-end encryption.');
|
||||
} else {
|
||||
alert('Failed to start chat: ' + e.message);
|
||||
}
|
||||
} finally { setSending(false); }
|
||||
} finally {
|
||||
setSending(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteConversation = async (deleteFor: 'self' | 'both') => {
|
||||
|
||||
Reference in New Issue
Block a user