fixes
This commit is contained in:
@@ -41,9 +41,24 @@ pub struct NoteUpdate {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct PresenceUser {
|
||||
pub name: String,
|
||||
pub compact_name: String,
|
||||
pub color: Option<String>,
|
||||
}
|
||||
|
||||
fn compact_presence_name(name: &str) -> String {
|
||||
let trimmed = name.trim();
|
||||
let Some((first, rest)) = trimmed.split_once('.') else {
|
||||
return trimmed.to_string();
|
||||
};
|
||||
if first.is_empty() || rest.is_empty() {
|
||||
return trimmed.to_string();
|
||||
}
|
||||
let Some(initial) = first.chars().next() else {
|
||||
return trimmed.to_string();
|
||||
};
|
||||
format!("{initial}.{rest}")
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct PresenceConnection {
|
||||
identity: String,
|
||||
@@ -158,6 +173,7 @@ impl AppState {
|
||||
PresenceConnection {
|
||||
identity,
|
||||
user: PresenceUser {
|
||||
compact_name: compact_presence_name(&nickname),
|
||||
name: nickname,
|
||||
color,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user