remove typing status in chat after 2 seconds

master
Aevann 2023-08-08 20:23:29 +03:00
parent 9e835fcece
commit da98e32ba8
1 changed files with 8 additions and 0 deletions

View File

@ -235,8 +235,15 @@ addEventListener('focus', function(){
focused=true
})
let timer_id;
function remove_typing() {
is_typing = false;
socket.emit('typing', false);
}
ta.addEventListener("input", function() {
clearTimeout(timer_id)
text = ta.value
if (!text && is_typing){
is_typing = false;
@ -245,6 +252,7 @@ ta.addEventListener("input", function() {
else if (text && !is_typing) {
is_typing = true;
socket.emit('typing', true);
timer_id = setTimeout(remove_typing, 2000);
}
})