|
|
@ -9,14 +9,24 @@ export const MsgTyping = (function() { |
|
|
|
const usersTyping = {}; |
|
|
|
const usersTyping = {}; |
|
|
|
const dep = new Tracker.Dependency; |
|
|
|
const dep = new Tracker.Dependency; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const shownName = function(user) { |
|
|
|
|
|
|
|
if (!user) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (RocketChat.settings.get('UI_Use_Real_Name')) { |
|
|
|
|
|
|
|
return user.name; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return user.username; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const addStream = function(room) { |
|
|
|
const addStream = function(room) { |
|
|
|
if (!_.isEmpty(usersTyping[room] && usersTyping[room].users)) { |
|
|
|
if (!_.isEmpty(usersTyping[room] && usersTyping[room].users)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
usersTyping[room] = { users: {} }; |
|
|
|
usersTyping[room] = { users: {} }; |
|
|
|
return RocketChat.Notifications.onRoom(room, 'typing', function(username, typing) { |
|
|
|
return RocketChat.Notifications.onRoom(room, 'typing', function(username, typing) { |
|
|
|
const user = Meteor.user(); |
|
|
|
const user = Meteor.users.findOne(Meteor.userId(), { fields: { name: 1, username: 1 } }); |
|
|
|
if (username === (user && user.username)) { |
|
|
|
if (username === shownName(user)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
const { users } = usersTyping[room]; |
|
|
|
const { users } = usersTyping[room]; |
|
|
@ -43,7 +53,7 @@ export const MsgTyping = (function() { |
|
|
|
timeouts[room] = null; |
|
|
|
timeouts[room] = null; |
|
|
|
} |
|
|
|
} |
|
|
|
const user = Meteor.user(); |
|
|
|
const user = Meteor.user(); |
|
|
|
return RocketChat.Notifications.notifyRoom(room, 'typing', user && user.username, false); |
|
|
|
return RocketChat.Notifications.notifyRoom(room, 'typing', shownName(user), false); |
|
|
|
}; |
|
|
|
}; |
|
|
|
const start = function(room) { |
|
|
|
const start = function(room) { |
|
|
|
if (!renew) { return; } |
|
|
|
if (!renew) { return; } |
|
|
@ -53,7 +63,7 @@ export const MsgTyping = (function() { |
|
|
|
renew = false; |
|
|
|
renew = false; |
|
|
|
selfTyping.set(true); |
|
|
|
selfTyping.set(true); |
|
|
|
const user = Meteor.user(); |
|
|
|
const user = Meteor.user(); |
|
|
|
RocketChat.Notifications.notifyRoom(room, 'typing', user && user.username, true); |
|
|
|
RocketChat.Notifications.notifyRoom(room, 'typing', shownName(user), true); |
|
|
|
clearTimeout(timeouts[room]); |
|
|
|
clearTimeout(timeouts[room]); |
|
|
|
return timeouts[room] = Meteor.setTimeout(() => stop(room), timeout); |
|
|
|
return timeouts[room] = Meteor.setTimeout(() => stop(room), timeout); |
|
|
|
}; |
|
|
|
}; |
|
|
|