timeline: add simple hashtag timeline constructor

Useful for adding hashtag timelines manually without the
into_timeline thing

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2024-11-29 10:34:18 -08:00
parent 37ab6f33fb
commit c8d95aca2a
2 changed files with 14 additions and 12 deletions

View File

@@ -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 {

View File

@@ -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))
}