Continued work on 'The Network' theme, fixed username colors for buffered chats from offline users.
This commit is contained in:
parent
3ea702b96d
commit
90e3589591
3 changed files with 100 additions and 40 deletions
|
|
@ -102,6 +102,27 @@ class userList{
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly assigns and gets a color to usernames that aren't on the colormap
|
||||
* @param {String} user username to assign a color
|
||||
*/
|
||||
assignColor(user){
|
||||
//if this user wasn't in the previous colormap
|
||||
if(this.colorMap.get(user) == null){
|
||||
//randomly pick a color
|
||||
let color = this.userColors[Math.floor(Math.random()*this.userColors.length)]
|
||||
|
||||
//Store new randomly selected color
|
||||
this.colorMap.set(user, color);
|
||||
|
||||
//Return color
|
||||
return color;
|
||||
}else{
|
||||
//Return color from previous entry
|
||||
return this.colorMap.get(user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates UX after user list change
|
||||
* @param {Array} list - Userlist data from server
|
||||
|
|
@ -116,19 +137,8 @@ class userList{
|
|||
|
||||
//for each user
|
||||
list.forEach((user) => {
|
||||
//randomly pick a color
|
||||
var color = this.userColors[Math.floor(Math.random()*this.userColors.length)]
|
||||
|
||||
//if this user wasn't in the previous colormap
|
||||
if(this.colorMap.get(user.user) == null){
|
||||
//Store new randomly selected color
|
||||
this.colorMap.set(user.user, color);
|
||||
}else{
|
||||
//Use color from previous entry
|
||||
color = this.colorMap.get(user.user);
|
||||
}
|
||||
|
||||
this.renderUser(user, color);
|
||||
//Assign color and render user
|
||||
this.renderUser(user, this.assignColor(user.user));
|
||||
});
|
||||
|
||||
//Make sure we're not cutting the ux off
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue