socketio changes
This commit is contained in:
@@ -665,23 +665,19 @@ $(document).ready(function() {
|
||||
response: response,
|
||||
socketId: socket.id
|
||||
});
|
||||
if (response.success && response.message) {
|
||||
if (response.success) {
|
||||
messageInput.val('');
|
||||
fileInput.value = '';
|
||||
$('#selectedFiles').text('');
|
||||
|
||||
// If socket is disconnected, append message directly
|
||||
if (!state.connectionState.isConnected) {
|
||||
try {
|
||||
appendMessage(response.message);
|
||||
} catch (error) {
|
||||
console.error('Error appending message:', error);
|
||||
// Refresh the page to show the new message
|
||||
window.location.reload();
|
||||
}
|
||||
if (!state.connectionState.isConnected && response.message) {
|
||||
console.log('Socket disconnected, appending message directly');
|
||||
appendMessage(response.message);
|
||||
}
|
||||
} else {
|
||||
console.error('Invalid response format:', response);
|
||||
console.error('Message send failed:', response);
|
||||
alert('Failed to send message. Please try again.');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
|
||||
Reference in New Issue
Block a user