From 8fe0615e689fd3417978190b1b772fec694be5ea Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Fri, 26 Jun 2020 17:48:40 -0300 Subject: [PATCH] [FIX] Typing when UI_Use_Real_Name is enabled (#2216) Co-authored-by: Diego Mello --- app/lib/methods/subscriptions/room.js | 10 ++++++---- app/lib/rocketchat.js | 9 ++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/lib/methods/subscriptions/room.js b/app/lib/methods/subscriptions/room.js index 8dfb45d0..320aab52 100644 --- a/app/lib/methods/subscriptions/room.js +++ b/app/lib/methods/subscriptions/room.js @@ -89,12 +89,14 @@ export default class RoomSubscription { } if (ev === 'typing') { const { user } = reduxStore.getState().login; - const [username, typing] = ddpMessage.fields.args; - if (username !== user.username) { + const { UI_Use_Real_Name } = reduxStore.getState().settings; + const [name, typing] = ddpMessage.fields.args; + const key = UI_Use_Real_Name ? 'name' : 'username'; + if (name !== user[key]) { if (typing) { - reduxStore.dispatch(addUserTyping(username)); + reduxStore.dispatch(addUserTyping(name)); } else { - reduxStore.dispatch(removeUserTyping(username)); + reduxStore.dispatch(removeUserTyping(name)); } } } else if (ev === 'deleteMessage') { diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 60fd9f76..fa207372 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -705,9 +705,12 @@ const RocketChat = { onStreamData(...args) { return this.sdk.onStreamData(...args); }, - emitTyping(room, t = true) { - const { login } = reduxStore.getState(); - return this.methodCall('stream-notify-room', `${ room }/typing`, login.user.username, t); + emitTyping(room, typing = true) { + const { login, settings } = reduxStore.getState(); + const { UI_Use_Real_Name } = settings; + const { user } = login; + const name = UI_Use_Real_Name ? user.name : user.username; + return this.methodCall('stream-notify-room', `${ room }/typing`, name, typing); }, setUserPresenceAway() { return this.methodCall('UserPresence:away');