From c8d95aca2aabdd3fb50866690257ca751513d883 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Fri, 29 Nov 2024 10:34:18 -0800 Subject: [PATCH] timeline: add simple hashtag timeline constructor Useful for adding hashtag timelines manually without the into_timeline thing Signed-off-by: William Casarin --- src/timeline/kind.rs | 13 +------------ src/timeline/mod.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/timeline/kind.rs b/src/timeline/kind.rs index 05b5d04..5196081 100644 --- a/src/timeline/kind.rs +++ b/src/timeline/kind.rs @@ -129,18 +129,7 @@ impl TimelineKind { )) } - TimelineKind::Hashtag(hashtag) => { - let filter = Filter::new() - .kinds([1]) - .limit(filter::default_limit()) - .tags([hashtag.clone()], 't') - .build(); - - Some(Timeline::new( - TimelineKind::Hashtag(hashtag), - FilterState::ready(vec![filter]), - )) - } + TimelineKind::Hashtag(hashtag) => Some(Timeline::hashtag(hashtag)), TimelineKind::List(ListKind::Contact(pk_src)) => { let pk = match &pk_src { diff --git a/src/timeline/mod.rs b/src/timeline/mod.rs index ca7a76b..c31e5a5 100644 --- a/src/timeline/mod.rs +++ b/src/timeline/mod.rs @@ -207,6 +207,19 @@ impl Timeline { )) } + pub fn hashtag(hashtag: String) -> Self { + let filter = Filter::new() + .kinds([1]) + .limit(filter::default_limit()) + .tags([hashtag.clone()], 't') + .build(); + + Timeline::new( + TimelineKind::Hashtag(hashtag), + FilterState::ready(vec![filter]), + ) + } + pub fn make_view_id(id: TimelineId, selected_view: i32) -> egui::Id { egui::Id::new((id, selected_view)) }