Update {user} is typing.. based on display name setting (#2817)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
b07f8272d6
Коммит
65a2427b90
@@ -33,16 +33,16 @@ class UserTypingStoreClass extends EventEmitter {
|
|||||||
this.removeListener(CHANGE_EVENT, callback);
|
this.removeListener(CHANGE_EVENT, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
usernameFromId(userId) {
|
nameFromId(userId) {
|
||||||
let username = Utils.localizeMessage('msg_typing.someone', 'Someone');
|
let name = Utils.localizeMessage('msg_typing.someone', 'Someone');
|
||||||
if (UserStore.hasProfile(userId)) {
|
if (UserStore.hasProfile(userId)) {
|
||||||
username = UserStore.getProfile(userId).username;
|
name = Utils.displayUsername(userId);
|
||||||
}
|
}
|
||||||
return username;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
userTyping(channelId, userId, postParentId) {
|
userTyping(channelId, userId, postParentId) {
|
||||||
const username = this.usernameFromId(userId);
|
const name = this.nameFromId(userId);
|
||||||
|
|
||||||
// Key representing a location where users can type
|
// Key representing a location where users can type
|
||||||
const loc = channelId + postParentId;
|
const loc = channelId + postParentId;
|
||||||
@@ -53,15 +53,15 @@ class UserTypingStoreClass extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we already have this user, clear it's timeout to be deleted
|
// If we already have this user, clear it's timeout to be deleted
|
||||||
if (this.typingUsers[loc][username]) {
|
if (this.typingUsers[loc][name]) {
|
||||||
clearTimeout(this.typingUsers[loc][username].timeout);
|
clearTimeout(this.typingUsers[loc][name].timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the user and a timeout to remove it
|
// Set the user and a timeout to remove it
|
||||||
this.typingUsers[loc][username] = setTimeout(() => {
|
this.typingUsers[loc][name] = setTimeout(() => {
|
||||||
delete this.typingUsers[loc][username];
|
Reflect.deleteProperty(this.typingUsers[loc], name);
|
||||||
if (this.typingUsers[loc] === {}) {
|
if (this.typingUsers[loc] === {}) {
|
||||||
delete this.typingUsers[loc];
|
Reflect.deleteProperty(this.typingUsers, loc);
|
||||||
}
|
}
|
||||||
this.emitChange();
|
this.emitChange();
|
||||||
}, Constants.UPDATE_TYPING_MS);
|
}, Constants.UPDATE_TYPING_MS);
|
||||||
@@ -76,14 +76,14 @@ class UserTypingStoreClass extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
userPosted(userId, channelId, postParentId) {
|
userPosted(userId, channelId, postParentId) {
|
||||||
const username = this.usernameFromId(userId);
|
const name = this.nameFromId(userId);
|
||||||
const loc = channelId + postParentId;
|
const loc = channelId + postParentId;
|
||||||
|
|
||||||
if (this.typingUsers[loc]) {
|
if (this.typingUsers[loc]) {
|
||||||
clearTimeout(this.typingUsers[loc][username]);
|
clearTimeout(this.typingUsers[loc][name]);
|
||||||
delete this.typingUsers[loc][username];
|
Reflect.deleteProperty(this.typingUsers[loc], name);
|
||||||
if (this.typingUsers[loc] === {}) {
|
if (this.typingUsers[loc] === {}) {
|
||||||
delete this.typingUsers[loc];
|
Reflect.deleteProperty(this.typingUsers, loc);
|
||||||
}
|
}
|
||||||
this.emitChange();
|
this.emitChange();
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user