Add character limit and check validation of messages in Chat

This commit is contained in:
anhkha2003 2024-01-16 00:46:18 -06:00
parent 995ff88c87
commit 89f396ff23
7 changed files with 43 additions and 10 deletions

View file

@ -88,7 +88,7 @@
</ul>
</div>
<div id="chat-input-container">
<textarea maxlength="5000" id="chat-input" placeholder="{{_('Enter your message')}}"></textarea>
<textarea maxlength="{{5000 if room else 200}}" id="chat-input" placeholder="{{_('Enter your message')}}"></textarea>
<div class="chat-input-icon" id="emoji-button" href="#" title="{{_('Emoji')}}"><i class="icofont-slightly-smile"></i>
</div>
<div class="chat-input-icon" id="submit-button">

View file

@ -243,6 +243,9 @@
$.post("{{ url('post_chat_message') }}", message)
.fail(function(res) {
console.log('Fail to send message');
var $body = $('#message-text-'+ message.tmp_id);
$body.css('text-decoration', 'line-through');
$body.css('background', 'red');
})
.done(function(res, status) {
$('#empty_msg').hide();
@ -307,6 +310,7 @@
refresh_status(true);
$('#chat-input').focus();
show_right_panel();
$('#chat-input').val('').trigger('input');
}
window.lock_click_space = true;
if (encrypted_user) {
@ -316,6 +320,7 @@
window.other_user_id = data.other_user_id;
color_selected_room();
callback();
$('#chat-input').attr('maxlength', 5000);
})
.fail(function() {
console.log('Fail to get_or_create_room');
@ -326,6 +331,7 @@
window.other_user_id = '';
color_selected_room();
callback();
$('#chat-input').attr('maxlength', 200);
}
window.lock_click_space = false;
}

View file

@ -23,7 +23,7 @@
{{_('Mute')}}
</a>
{% endif %}
<div class="message-text message-text-other">
<div class="message-text message-text-other" id="message-text-{{ message.id }}">
{{message.body|markdown(lazy_load=False)|reference|str|safe }}
</div>
</div>

View file

@ -6,4 +6,5 @@
{% endfor %}
{% else %}
<center id="empty_msg">{{_('You are connect now. Say something to start the conversation.')}}</center>
{% endif %}
{% endif %}