From 5aa353ca4cd9cb9ab1770e6c6736e2ac942582e6 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 2 Feb 2024 14:45:33 +0000 Subject: [PATCH] Tolerate hidden number of followers in Account This can be -1. Display `(hidden)` when it's not available. --- src/text.rs | 11 ++++++++--- src/types.rs | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/text.rs b/src/text.rs index be1ab9e..25b8b87 100644 --- a/src/text.rs +++ b/src/text.rs @@ -3,6 +3,7 @@ use chrono::NaiveDateTime; use chrono::{DateTime, Local, Utc}; use core::cmp::{max, min}; use std::collections::{BTreeMap, HashSet}; +use std::fmt::Display; use unicode_width::UnicodeWidthStr; use super::client::{Client, ClientError}; @@ -3027,9 +3028,13 @@ impl ExamineUserDisplay { let post_count = Paragraph::new().add(ColouredString::plain( &format!("Number of posts: {}", ac.statuses_count), )); - let followers_count = Paragraph::new().add(ColouredString::plain( - &format!("Number of followers: {}", ac.followers_count), - )); + let followers_count = Paragraph::new().add(ColouredString::plain(&{ + let followers_count = u64::try_from(ac.followers_count); + format!("Number of followers: {}", match &followers_count { + Ok(y) => y as &dyn Display, + Err(_) => &"(hidden)", + }) + })); let following_count = Paragraph::new().add(ColouredString::plain( &format!("Number of users followed: {}", ac.following_count), )); diff --git a/src/types.rs b/src/types.rs index ccc8c03..56f5532 100644 --- a/src/types.rs +++ b/src/types.rs @@ -123,7 +123,7 @@ pub struct Account { pub created_at: ApproxDate, pub last_status_at: Option, pub statuses_count: u64, - pub followers_count: u64, + pub followers_count: i64, pub following_count: u64, // In the wire protocol, 'CredentialAccount' is a subclass of -- 2.30.2