move name coloring out of sender profile

so we can reuse it in room preview bar
This commit is contained in:
Bruno Windels 2019-04-17 10:21:30 +02:00
parent 56ade1ead5
commit eeaa7143ac
4 changed files with 43 additions and 36 deletions

View file

@ -58,3 +58,8 @@ export function hashCode(str) {
}
return Math.abs(hash);
}
export function getUserNameColorClass(userId) {
const colorNumber = (hashCode(userId) % 8) + 1;
return `mx_Username_color${colorNumber}`;
}