chiark / gitweb /
Fix title of user_posts files.
authorSimon Tatham <anakin@pobox.com>
Sat, 13 Jan 2024 14:09:57 +0000 (14:09 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 13 Jan 2024 14:09:57 +0000 (14:09 +0000)
Ahem. Copy-paste error from another constructor function!

src/file.rs

index 0ca8bb263192dff8dc4364f001b47407d49b2445..72932ed7eea33a5db0fad27a47826dd032338e22 100644 (file)
@@ -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   <P>",
-            "HHHHHHHHHHHHHHHHHHHKH"), desc, pos, Some(unfolded), false)?;
+        client, FeedSource::new(feed), ColouredString::uniform(&title, 'H'),
+        desc, pos, Some(unfolded), false)?;
     Ok(Box::new(file))
 }