Fix avatar colors and text capitalization
This commit is contained in:
parent
14f586faad
commit
b53636ec19
@ -1,25 +1,10 @@
|
||||
import stringHash from 'string-hash';
|
||||
import { check } from 'meteor/check';
|
||||
|
||||
import addUser from '../modifiers/addUser';
|
||||
|
||||
const COLOR_LIST = [
|
||||
'#d32f2f', '#c62828', '#b71c1c', '#d81b60', '#c2185b', '#ad1457', '#880e4f',
|
||||
'#8e24aa', '#7b1fa2', '#6a1b9a', '#4a148c', '#5e35b1', '#512da8', '#4527a0',
|
||||
'#311b92', '#3949ab', '#303f9f', '#283593', '#1a237e', '#1976d2', '#1565c0',
|
||||
'#0d47a1', '#0277bd', '#01579b', '#00838f', '#006064', '#00796b', '#00695c',
|
||||
'#004d40', '#2e7d32', '#1b5e20', '#33691e', '#827717', '#bf360c', '#6d4c41',
|
||||
'#5d4037', '#4e342e', '#3e2723', '#757575', '#616161', '#424242', '#212121',
|
||||
'#546e7a', '#455a64', '#37474f', '#263238',
|
||||
];
|
||||
|
||||
export default function handleUserJoined({ body }, meetingId) {
|
||||
const user = body;
|
||||
check(user, Object);
|
||||
|
||||
/* While the akka-apps dont generate a color we just pick one
|
||||
from a list based on the userId */
|
||||
const color = COLOR_LIST[stringHash(user.intId) % COLOR_LIST.length];
|
||||
|
||||
return addUser(meetingId, Object.assign(user, { color }));
|
||||
return addUser(meetingId, user);
|
||||
}
|
||||
|
@ -1,9 +1,22 @@
|
||||
import { check } from 'meteor/check';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import Users from '/imports/api/2.0/users';
|
||||
|
||||
import stringHash from 'string-hash';
|
||||
import flat from 'flat';
|
||||
|
||||
import addVoiceUser from '/imports/api/2.0/voice-users/server/modifiers/addVoiceUser';
|
||||
|
||||
const COLOR_LIST = [
|
||||
'#d32f2f', '#c62828', '#b71c1c', '#d81b60', '#c2185b', '#ad1457', '#880e4f',
|
||||
'#8e24aa', '#7b1fa2', '#6a1b9a', '#4a148c', '#5e35b1', '#512da8', '#4527a0',
|
||||
'#311b92', '#3949ab', '#303f9f', '#283593', '#1a237e', '#1976d2', '#1565c0',
|
||||
'#0d47a1', '#0277bd', '#01579b', '#00838f', '#006064', '#00796b', '#00695c',
|
||||
'#004d40', '#2e7d32', '#1b5e20', '#33691e', '#827717', '#bf360c', '#6d4c41',
|
||||
'#5d4037', '#4e342e', '#3e2723', '#757575', '#616161', '#424242', '#212121',
|
||||
'#546e7a', '#455a64', '#37474f', '#263238',
|
||||
];
|
||||
|
||||
export default function addUser(meetingId, user) {
|
||||
check(meetingId, String);
|
||||
|
||||
@ -54,6 +67,10 @@ export default function addUser(meetingId, user) {
|
||||
userRole === ROLE_MODERATOR ? 'moderator' : false,
|
||||
].filter(Boolean);
|
||||
|
||||
/* While the akka-apps dont generate a color we just pick one
|
||||
from a list based on the userId */
|
||||
const color = COLOR_LIST[stringHash(user.intId) % COLOR_LIST.length];
|
||||
|
||||
const modifier = {
|
||||
$set: Object.assign(
|
||||
{
|
||||
@ -61,6 +78,7 @@ export default function addUser(meetingId, user) {
|
||||
connectionStatus: 'online',
|
||||
roles: userRoles,
|
||||
sortName: user.name.trim().toLowerCase(),
|
||||
color,
|
||||
},
|
||||
flat(user),
|
||||
),
|
||||
|
@ -135,7 +135,7 @@ export default class MessageListItem extends Component {
|
||||
color={user.color}
|
||||
moderator={user.isModerator}
|
||||
>
|
||||
{user.name.slice(0, 2)}
|
||||
{user.name.toLowerCase().slice(0, 2)}
|
||||
</UserAvatar>
|
||||
</div>
|
||||
<div className={styles.content}>
|
||||
|
@ -364,7 +364,7 @@ class UserListItem extends Component {
|
||||
>
|
||||
{user.emoji.status !== 'none' ?
|
||||
<Icon iconName={normalizeEmojiName(user.emoji.status)} /> :
|
||||
user.name.slice(0, 2)}
|
||||
user.name.toLowerCase().slice(0, 2)}
|
||||
</UserAvatar>
|
||||
</div>
|
||||
{this.renderUserName()}
|
||||
|
@ -12,6 +12,8 @@ const mapUser = (user) => {
|
||||
const mappedUser = {
|
||||
id: user.userId,
|
||||
name: user.name,
|
||||
color: user.color,
|
||||
avatar: user.avatar,
|
||||
emoji: {
|
||||
status: user.emoji,
|
||||
changedAt: user.emojiTime,
|
||||
|
Loading…
Reference in New Issue
Block a user