mirror of
https://github.com/aljazceru/notedeck.git
synced 2026-01-20 08:44:22 +01:00
profiles: introduce DisplayNames
This is exactly the same as the DisplayName enum in Damus iOS. Due to the various inconsistencies in `name` and `display_name` between clients, we have to generalize DisplayName into two variants: one name or two names. If we have two names, we treat it in the standard way of display_name is the real name, and `name` is the username. If only one is set, then it is considered both the username and "real name". Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::app_style::NotedeckTextStyle;
|
||||
use crate::images;
|
||||
use crate::DisplayName;
|
||||
use egui::load::TexturePoll;
|
||||
use egui::{RichText, Sense};
|
||||
use egui_extras::Size;
|
||||
@@ -58,14 +59,29 @@ impl<'a> ProfilePreview<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn body(ui: &mut egui::Ui, profile: &ProfileRecord<'_>) -> egui::Response {
|
||||
fn body(ui: &mut egui::Ui, profile: &ProfileRecord<'_>) {
|
||||
let name = if let Some(name) = crate::profile::get_profile_name(profile) {
|
||||
name
|
||||
} else {
|
||||
"nostrich"
|
||||
DisplayName::One("??")
|
||||
};
|
||||
|
||||
ui.label(RichText::new(name).text_style(NotedeckTextStyle::Heading3.text_style()))
|
||||
match name {
|
||||
DisplayName::One(n) => {
|
||||
ui.label(RichText::new(n).text_style(NotedeckTextStyle::Heading3.text_style()));
|
||||
}
|
||||
|
||||
DisplayName::Both {
|
||||
display_name,
|
||||
username,
|
||||
} => {
|
||||
ui.label(
|
||||
RichText::new(display_name)
|
||||
.text_style(NotedeckTextStyle::Heading3.text_style()),
|
||||
);
|
||||
ui.label(RichText::new(format!("@{}", username)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user