No trouble at all given the existing infrastructure.
PublicTimelineFile,
LocalTimelineFile,
SinglePost(String),
+ HashtagTimeline(String),
}
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum OverlayActivity {
GetUserToExamine,
GetPostIdToRead,
+ GetHashtagToRead,
}
#[derive(PartialEq, Eq, Debug, Clone)]
})
))
}
+
+pub fn get_hashtag_to_read() -> Box<dyn ActivityState> {
+ Box::new(BottomLineEditorOverlay::new(
+ ColouredString::plain("View feed for hashtag: "),
+ Box::new(move |s, _client| {
+ let s = s.trim();
+ let s = s.strip_prefix("#").unwrap_or(s);
+ if s.is_empty() {
+ LogicalAction::PopOverlaySilent
+ } else {
+ LogicalAction::Goto(
+ NonUtilityActivity::HashtagTimeline(s.to_owned())
+ .into())
+ }
+ })
+ ))
+}
Ok(Box::new(file))
}
+pub fn hashtag_timeline(client: &mut Client, tag: &str) ->
+ Result<Box<dyn ActivityState>, ClientError>
+{
+ let title = ColouredString::uniform(
+ &format!("Posts mentioning hashtag #{tag}"), 'H');
+ let file = File::<StatusFeedType, _>::new(
+ client, FeedSource::new(FeedId::Hashtag(tag.to_owned())), title)?;
+ Ok(Box::new(file))
+}
+
struct ExamineUserFileType {}
impl FileType for ExamineUserFileType {
type Item = ExamineUserDisplay;
menu.add_action(Pr('L'), "Local public timeline (this server)",
LogicalAction::Goto(
NonUtilityActivity::LocalTimelineFile.into()));
- menu.add_action(Pr('#'), "Timeline for a #hashtag",
- LogicalAction::NYI);
+ menu.add_action(Pr('#'), "Timeline for a #hashtag", LogicalAction::Goto(
+ OverlayActivity::GetHashtagToRead.into()));
menu.add_blank_line();
menu.add_action(Pr('I'), "View a post by its ID", LogicalAction::Goto(
OverlayActivity::GetPostIdToRead.into()));
public_timeline(client),
Activity::NonUtil(NonUtilityActivity::LocalTimelineFile) =>
local_timeline(client),
+ Activity::NonUtil(NonUtilityActivity::HashtagTimeline(ref id)) =>
+ hashtag_timeline(client, id),
Activity::Util(UtilityActivity::ReadMentions) =>
mentions(client),
Activity::Util(UtilityActivity::EgoLog) =>
Ok(get_user_to_examine()),
Activity::Overlay(OverlayActivity::GetPostIdToRead) =>
Ok(get_post_id_to_read()),
+ Activity::Overlay(OverlayActivity::GetHashtagToRead) =>
+ Ok(get_hashtag_to_read()),
Activity::Util(UtilityActivity::ExamineUser(ref name)) =>
examine_user(client, name),
Activity::NonUtil(NonUtilityActivity::SinglePost(ref id)) =>