mirror of
https://github.com/pierre42100/ComunicWeb
synced 2025-06-19 12:25:16 +00:00
Send notification when user is writing a message
This commit is contained in:
@ -146,6 +146,9 @@ const ConvChatWindow = {
|
||||
});
|
||||
inputText.maxLength = ServerConfig.conf.max_conversation_message_len;
|
||||
|
||||
// Notify other users when this user is writing a message
|
||||
ConversationsUtils.listenToInputChangeEvents(inputText, infosBox.conversationID)
|
||||
|
||||
//Enable textarea 2.0 on the message
|
||||
var textarea2 = new ComunicWeb.components.textarea();
|
||||
textarea2.init({
|
||||
|
@ -284,6 +284,30 @@ const ConversationsUtils = {
|
||||
|
||||
await ConversationsInterface.sendNewConversationImage(convID, input);
|
||||
},
|
||||
|
||||
/**
|
||||
* Automatically listen to change events of an input
|
||||
* to notify other users current user is writing a message
|
||||
*
|
||||
* @param {HTMLInputElement} input
|
||||
* @param {number} convID
|
||||
*/
|
||||
listenToInputChangeEvents: async function(input, convID) {
|
||||
let last_update = 0;
|
||||
|
||||
input.addEventListener("keyup", e => {
|
||||
if(input.value == "")
|
||||
return;
|
||||
|
||||
const t = ComunicDate.time();
|
||||
if (t - last_update < ServerConfig.conf.conversation_writing_event_interval)
|
||||
return;
|
||||
|
||||
last_update = t;
|
||||
ws("conversations/writing", {convID: convID});
|
||||
});
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
ComunicWeb.components.conversations.utils = ConversationsUtils;
|
||||
|
Reference in New Issue
Block a user