[FIX] Typing when UI_Use_Real_Name is enabled (#2216)

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-06-26 17:48:40 -03:00 committed by GitHub
parent ff74f6ec9e
commit 8fe0615e68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

@ -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') {

View File

@ -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');