web: more robust avatar intial filtering
This commit is contained in:
parent
d5fa89b38c
commit
e0863ac085
@ -444,8 +444,10 @@ fn has_unread(tags: &[String]) -> bool {
|
|||||||
fn render_avatar(avatar: Option<String>, from: &str) -> Node<Msg> {
|
fn render_avatar(avatar: Option<String>, from: &str) -> Node<Msg> {
|
||||||
let initials: String = from
|
let initials: String = from
|
||||||
.to_lowercase()
|
.to_lowercase()
|
||||||
|
.trim()
|
||||||
.split(" ")
|
.split(" ")
|
||||||
.map(|word| word.chars().next().unwrap())
|
.map(|word| word.chars().next().unwrap())
|
||||||
|
.filter(|c| c.is_alphanumeric())
|
||||||
// Limit to 2 characters because more characters don't fit in the box
|
// Limit to 2 characters because more characters don't fit in the box
|
||||||
.take(2)
|
.take(2)
|
||||||
.collect();
|
.collect();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user