Ready to implement conversation message writing notifier

This commit is contained in:
Pierre HUBERT 2021-03-08 19:01:51 +01:00
parent a545860795
commit 3a55f18b96
6 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,12 @@
/**
* Conversation message writing notifier
*/
.user-writing-message {
font-size: 80%;
font-style: italic;
}
#conversationsElem .user-writing-message {
margin-top: -12px;
}

View File

@ -197,6 +197,10 @@ class UserWebSocket {
SendEvent("newNumberUnreadConvs", msg.data) SendEvent("newNumberUnreadConvs", msg.data)
break; break;
case "writing_message_in_conv":
SendEvent("WritingMessageInConv", msg.data);
break;
case "new_conv_message": case "new_conv_message":
SendEvent("newConvMessage", msg.data); SendEvent("newConvMessage", msg.data);
break; break;

View File

@ -130,6 +130,8 @@ const ConvChatWindow = {
class: "create-message-form" class: "create-message-form"
}); });
new ConversationWritingNotifier(conversationFormContainer, infosBox.conversationID)
//Create input group //Create input group
var inputGroup = createElem2({ var inputGroup = createElem2({
appendTo: conversationFormContainer, appendTo: conversationFormContainer,

View File

@ -0,0 +1,31 @@
/**
* Notify when a user is writing a new message
* in a conversation
*
* @author Pierre Hubert
*/
class ConversationWritingNotifier {
constructor(target, convID) {
this.messageArea = createElem2({
appendTo: target,
type: "div",
class: "user-writing-message"
})
this.setText("hello world for conv " + convID)
}
/**
* Update message. If message is empty, hide the area
*
* @param {String} msg
*/
setText(msg) {
if(msg.length == 0)
return this.messageArea.style.display = "none";
this.messageArea.style.display = "block";
this.messageArea.innerHTML = msg;
}
}

View File

@ -407,6 +407,8 @@ const ConversationPageConvPart = {
emptyElem(formContainer); emptyElem(formContainer);
} }
new ConversationWritingNotifier(formContainer, this._conv_info.id)
//Add message input //Add message input
var inputGroup = createElem2({ var inputGroup = createElem2({
appendTo: formContainer, appendTo: formContainer,

View File

@ -208,6 +208,7 @@ class Dev {
"css/components/conversations/windows.css", "css/components/conversations/windows.css",
"css/components/conversations/list.css", "css/components/conversations/list.css",
"css/components/conversations/unreadDropdown.css", "css/components/conversations/unreadDropdown.css",
"css/components/conversations/writingNotifier.css",
//User selector stylesheet //User selector stylesheet
"css/components/userSelect/userSelect.css", "css/components/userSelect/userSelect.css",
@ -405,6 +406,7 @@ class Dev {
"js/components/conversations/utils.js", "js/components/conversations/utils.js",
"js/components/conversations/unreadDropdown.js", "js/components/conversations/unreadDropdown.js",
"js/components/conversations/messageEditor.js", "js/components/conversations/messageEditor.js",
"js/components/conversations/writingNotifier.js",
//User selector //User selector
"js/components/userSelect/userSelect.js", "js/components/userSelect/userSelect.js",