From: Simon Tatham Date: Mon, 1 Jan 2024 12:05:24 +0000 (+0000) Subject: Filled in account flags. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=164733f9eb1f9ed94ccd88fd856d7331a270f7cb;p=mastodonochrome.git Filled in account flags. I think that's Examine User all done now! --- diff --git a/src/text.rs b/src/text.rs index 1833dbd..fefb89d 100644 --- a/src/text.rs +++ b/src/text.rs @@ -1492,6 +1492,7 @@ pub struct ExamineUserDisplay { post_count: Paragraph, followers_count: Paragraph, following_count: Paragraph, + flags: Vec, relationships: Vec, blank: BlankLine, } @@ -1545,6 +1546,42 @@ impl ExamineUserDisplay { .add(&ColouredString::plain( &format!("Number of users followed: {}", ac.following_count))); + let mut flags = Vec::new(); + if ac.locked { + flags.push(Paragraph::new() + .add(&ColouredString::plain("This account is ")) + .add(&ColouredString::uniform("locked", 'r')) + .add(&ColouredString::plain( + " (you can't follow it without its permission)."))); + } + if ac.suspended.unwrap_or(false) { + flags.push(Paragraph::new().add( + &ColouredString::uniform( + "This account is suspended.", 'r'))); + } + if ac.limited.unwrap_or(false) { + flags.push(Paragraph::new().add( + &ColouredString::uniform( + "This account is silenced.", 'r'))); + } + if ac.bot { + flags.push(Paragraph::new().add( + &ColouredString::plain( + "This account identifies as a bot."))); + } + if ac.group { + flags.push(Paragraph::new().add( + &ColouredString::plain( + "This account identifies as a group."))); + } + if let Some(moved_to) = ac.moved { + flags.push(Paragraph::new() + .add(&ColouredString::uniform( + "This account has moved to:", 'r')) + .add(&ColouredString::plain( + &format!(" {}", client.fq(&moved_to.acct))))); + } + let mut relationships = Vec::new(); if ac.id == client.our_account_id() { relationships.push(Paragraph::new().set_indent(2, 2).add( @@ -1630,6 +1667,7 @@ impl ExamineUserDisplay { post_count, followers_count, following_count, + flags, relationships, blank: BlankLine::new(), }) @@ -1669,7 +1707,12 @@ impl TextFragment for ExamineUserDisplay { push_fragment(&mut lines, self.blank.render(width)); } - // FIXME: flags + if !self.flags.is_empty() { + for para in &self.flags { + push_fragment(&mut lines, para.render(width)); + } + push_fragment(&mut lines, self.blank.render(width)); + } if !self.relationships.is_empty() { for para in &self.relationships {