HomeTimelineFile,
PublicTimelineFile,
LocalTimelineFile,
+ SinglePost(String),
}
#[derive(PartialEq, Eq, Debug, Clone)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum OverlayActivity {
GetUserToExamine,
+ GetPostIdToRead,
}
#[derive(PartialEq, Eq, Debug, Clone)]
use unicode_width::UnicodeWidthChar;
-use super::activity_stack::UtilityActivity;
+use super::activity_stack::{NonUtilityActivity, UtilityActivity};
use super::client::Client;
use super::coloured_string::ColouredString;
use super::tui::{
})
))
}
+
+pub fn get_post_id_to_read() -> Box<dyn ActivityState> {
+ Box::new(BottomLineEditorOverlay::new(
+ ColouredString::plain("View post with id: "),
+ Box::new(move |s, client| {
+ let s = s.trim();
+ if s.is_empty() {
+ LogicalAction::PopOverlaySilent
+ } else {
+ match client.status_by_id(s) {
+ Ok(st) => LogicalAction::Goto(
+ NonUtilityActivity::SinglePost(st.id).into()),
+
+ // FIXME: it would be nice to discriminate errors
+ // better here, and maybe return anything worse
+ // than 'post not found' to the Error Log
+ Err(_) => LogicalAction::PopOverlayBeep,
+ }
+ }
+ })
+ ))
+}
client, SingletonSource::new(ac.id), title)?;
Ok(Box::new(file))
}
+
+struct DetailedStatusFileType {}
+impl FileType for DetailedStatusFileType {
+ type Item = StatusDisplay;
+
+ fn get_from_client(id: &str, client: &mut Client) ->
+ Result<Self::Item, ClientError>
+ {
+ let st = client.status_by_id(&id)?;
+ Ok(StatusDisplay::new(st.clone(), client)) // FIXME: .set_detailed()
+ }
+}
+
+pub fn view_single_post(client: &mut Client, status_id: &str) ->
+ Result<Box<dyn ActivityState>, ClientError>
+{
+ let st = client.status_by_id(status_id)?;
+ let title = ColouredString::uniform(
+ &format!("Information about post {}", st.id), 'H');
+
+ let file = File::<DetailedStatusFileType, _>::new(
+ client, SingletonSource::new(st.id), title)?;
+ Ok(Box::new(file))
+}
menu.add_action(Pr('#'), "Timeline for a #hashtag",
LogicalAction::NYI);
menu.add_blank_line();
- menu.add_action(Pr('I'), "View a post by its ID",
- LogicalAction::NYI);
+ menu.add_action(Pr('I'), "View a post by its ID", LogicalAction::Goto(
+ OverlayActivity::GetPostIdToRead.into()));
menu.add_blank_line();
menu.add_action(Pr('C'), "Compose a post",
LogicalAction::NYI);
ego_log(client),
Activity::Overlay(OverlayActivity::GetUserToExamine) =>
Ok(get_user_to_examine()),
+ Activity::Overlay(OverlayActivity::GetPostIdToRead) =>
+ Ok(get_post_id_to_read()),
Activity::Util(UtilityActivity::ExamineUser(ref name)) =>
examine_user(client, name),
+ Activity::NonUtil(NonUtilityActivity::SinglePost(ref id)) =>
+ view_single_post(client, id),
_ => todo!(),
};