Implement typing

parent 0d3aac04
......@@ -33,7 +33,11 @@ RocketChat.Notifications = new class
roomId = eventName.split('/')[0]
user = Meteor.users.findOne @userId, {fields: {username: 1}}
return RocketChat.models.Rooms.findOneByIdContainigUsername(roomId, user.username, {fields: {_id: 1}})?
room = RocketChat.models.Rooms.findOneById(roomId)
if room.t is 'l' and room.v._id is user._id
return true
return room.usernames.indexOf(user.username) > -1
@streamRoomUsers.allowRead('none');
......
......@@ -456,6 +456,15 @@ input:focus {
font-size: 0.65rem;
}
.typing {
clear: both;
color: @secondary-font-color;
margin-left: 8px;
outline: none;
margin-top: 2px;
font-size: 0.65rem;
}
.options-menu {
min-width: 100px;
// min-height: 40px;
......
......@@ -32,7 +32,28 @@
</div>
{{/if}}
{{> options show=showOptions}}
<button class="toggle-options">{{optionsLink}}</button>
{{#if usersTyping.users}}
{{#with usersTyping}}
<div class="typing">
<strong>{{users}}</strong>
{{#if multi}}
{{#if selfTyping}}
{{_ "are_also_typing"}}
{{else}}
{{_ "are_typing"}}
{{/if}}
{{else}}
{{#if selfTyping}}
{{_ "is_also_typing" context="male"}}
{{else}}
{{_ "is_typing" context="male"}}
{{/if}}
{{/if}}
</div>
{{/with}}
{{else}}
{{> options show=showOptions}}
<button class="toggle-options">{{optionsLink}}</button>
{{/if}}
</div>
</template>
/* globals Livechat, LivechatVideoCall */
/* globals Livechat, LivechatVideoCall, MsgTyping */
Template.messages.helpers({
messages() {
......@@ -32,6 +32,32 @@ Template.messages.helpers({
},
showConnecting() {
return Livechat.connecting;
},
usersTyping() {
const users = MsgTyping.get(visitor.getRoom());
if (users.length === 0) {
return;
}
if (users.length === 1) {
return {
multi: false,
selfTyping: MsgTyping.selfTyping.get(),
users: users[0]
};
}
// usernames = _.map messages, (message) -> return message.u.username
let last = users.pop();
if (users.length > 4) {
last = t('others');
}
// else
let usernames = users.join(', ');
usernames = [usernames, last];
return {
multi: true,
selfTyping: MsgTyping.selfTyping.get(),
users: usernames.join(` ${t('and')} `)
};
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment