From 49af30c07ad5112710124048668f51334621b140 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 13 Jan 2024 14:09:57 +0000 Subject: [PATCH] Fix title of user_posts files. Ahem. Copy-paste error from another constructor function! --- src/file.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/file.rs b/src/file.rs index 0ca8bb2..72932ed 100644 --- a/src/file.rs +++ b/src/file.rs @@ -1622,10 +1622,27 @@ pub fn user_posts( let feed = FeedId::User(user.to_owned(), boosts, replies); let pos = file_positions.get(&feed); let desc = StatusFeedType::with_feed(feed.clone()); + + let ac = client.account_by_id(user)?; + let username = client.fq(&ac.acct); + + let title = match (boosts, replies) { + (Boosts::Hide, Replies::Hide) => + format!("Top-level posts by {username}"), + (Boosts::Hide, Replies::Show) => + format!("Original posts by {username}"), + (Boosts::Show, Replies::Show) => + format!("All posts by {username}"), + // We don't currently have a UI for asking for this + // combination, but we can't leave it out of the match or Rust + // will complain, so we might as well write a title in case we + // ever decide to add it for some reason + (Boosts::Show, Replies::Hide) => + format!("Boosts and top-level posts by {username}"), + }; let file = File::new( - client, FeedSource::new(feed), ColouredString::general( - "Public timeline

", - "HHHHHHHHHHHHHHHHHHHKH"), desc, pos, Some(unfolded), false)?; + client, FeedSource::new(feed), ColouredString::uniform(&title, 'H'), + desc, pos, Some(unfolded), false)?; Ok(Box::new(file)) } -- 2.30.2