chiark / gitweb /
Fill in some fixed initial file positions.
authorSimon Tatham <anakin@pobox.com>
Thu, 4 Jan 2024 12:16:22 +0000 (12:16 +0000)
committerSimon Tatham <anakin@pobox.com>
Thu, 4 Jan 2024 12:16:22 +0000 (12:16 +0000)
Examine User and Post Info should start at the top, not the bottom,
now that we have the ability to do that easily.

And when you view the thread of a post, it makes sense to me to focus
_that post_ to start with!

src/file.rs

index 9ef42c3639369abb9b5624bbf1b7640d5aef2514..599775e9d9ad6b03c062dafb1e7f0af191a20a8f 100644 (file)
@@ -1217,7 +1217,8 @@ pub fn examine_user(client: &mut Client, account_id: &str) ->
         &format!("Information about user {username}"), 'H');
 
     let file = File::<ExamineUserFileType, _>::new(
-        client, StaticSource::singleton(ac.id), title, None)?;
+        client, StaticSource::singleton(ac.id), title,
+        Some(FilePosition::item_top(isize::MIN)))?;
     Ok(Box::new(file))
 }
 
@@ -1242,7 +1243,8 @@ pub fn view_single_post(client: &mut Client, status_id: &str) ->
         &format!("Information about post {}", st.id), 'H');
 
     let file = File::<DetailedStatusFileType, _>::new(
-        client, StaticSource::singleton(st.id), title, None)?;
+        client, StaticSource::singleton(st.id), title,
+        Some(FilePosition::item_top(isize::MIN)))?;
     Ok(Box::new(file))
 }
 
@@ -1277,7 +1279,12 @@ pub fn view_thread(client: &mut Client, start_id: &str, full: bool) ->
     };
     let title = ColouredString::uniform(&title, 'H');
 
+    // Focus the id in question, assuming we can
+    let index = ids.iter().position(|x| x == start_id)
+        .map_or(isize::MIN, |u| u as isize);
+
     let file = File::<StatusFeedType, _>::new(
-        client, StaticSource::vector(ids), title, None)?;
+        client, StaticSource::vector(ids), title,
+        Some(FilePosition::item_top(index as isize)))?;
     Ok(Box::new(file))
 }