🔧 Improve file transfer system integration and message handling
- File Transfer Integration: Refactored file transfer system initialization with better error handling and automatic retry mechanisms - Message Filtering: Added comprehensive message filtering system to prevent file transfer and system messages from appearing in chat UI - Callback System: Simplified file transfer callback system - removed progress notifications from chat to reduce noise - System Message Deduplication: Implemented notification flags to prevent duplicate system messages (verification, security upgrades, etc.) - Error Handling: Enhanced error handling with graceful fallbacks instead of throwing exceptions that could break connections - UI Message Delivery: Added `deliverMessageToUI()` method with built-in filtering for system/file messages - DataChannel Event Handling: Improved onmessage handler with early filtering for file transfer messages - Global Integration: Better integration with global file transfer system (`window.fileTransferSystem`) - Connection Stability: Removed aggressive reconnection attempts that could cause session closure - Debug Logging: Enhanced debug logging for better troubleshooting - File transfer messages now bypass chat UI entirely - System messages are deduplicated using internal flags - Better separation of concerns between WebRTC and file transfer systems - More robust initialization sequence with proper cleanup - Improved message routing and processing pipeline - Fixed duplicate system notifications - Resolved file transfer message leakage into chat - Improved connection state management - Better handling of initialization race conditions
This commit is contained in:
28
index.html
28
index.html
@@ -2963,6 +2963,34 @@
|
||||
}
|
||||
|
||||
const handleMessage = (message, type) => {
|
||||
// Дополнительная проверка на файловые и системные сообщения
|
||||
if (typeof message === 'string' && message.trim().startsWith('{')) {
|
||||
try {
|
||||
const parsedMessage = JSON.parse(message);
|
||||
const blockedTypes = [
|
||||
'file_transfer_start',
|
||||
'file_transfer_response',
|
||||
'file_chunk',
|
||||
'chunk_confirmation',
|
||||
'file_transfer_complete',
|
||||
'file_transfer_error',
|
||||
'heartbeat',
|
||||
'verification',
|
||||
'verification_response',
|
||||
'peer_disconnect',
|
||||
'key_rotation_signal',
|
||||
'key_rotation_ready',
|
||||
'security_upgrade'
|
||||
];
|
||||
if (parsedMessage.type && blockedTypes.includes(parsedMessage.type)) {
|
||||
console.log(`🛑 Blocked system/file message from chat: ${parsedMessage.type}`);
|
||||
return; // Не показываем системные и файловые сообщения в чате
|
||||
}
|
||||
} catch (parseError) {
|
||||
// Не JSON - это нормально для обычных текстовых сообщений
|
||||
}
|
||||
}
|
||||
|
||||
addMessageWithAutoScroll(message, type);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user