hashtag-column: allow multiple hashtags
Changelog-Changed: Allow multiple hashtags in hashtag columns
This commit is contained in:
committed by
William Casarin
parent
5c31bf16c8
commit
f214e97382
@@ -213,7 +213,7 @@ pub enum TimelineKind {
|
||||
/// Generic filter, references a hash of a filter
|
||||
Generic(u64),
|
||||
|
||||
Hashtag(String),
|
||||
Hashtag(Vec<String>),
|
||||
}
|
||||
|
||||
const NOTIFS_TOKEN_DEPRECATED: &str = "notifs";
|
||||
@@ -263,7 +263,7 @@ impl Display for TimelineKind {
|
||||
TimelineKind::Notifications(_) => f.write_str("Notifications"),
|
||||
TimelineKind::Profile(_) => f.write_str("Profile"),
|
||||
TimelineKind::Universe => f.write_str("Universe"),
|
||||
TimelineKind::Hashtag(_) => f.write_str("Hashtag"),
|
||||
TimelineKind::Hashtag(_) => f.write_str("Hashtags"),
|
||||
TimelineKind::Search(_) => f.write_str("Search"),
|
||||
}
|
||||
}
|
||||
@@ -325,7 +325,7 @@ impl TimelineKind {
|
||||
}
|
||||
TimelineKind::Hashtag(ht) => {
|
||||
writer.write_token("hashtag");
|
||||
writer.write_token(ht);
|
||||
writer.write_token(&ht.join(" "));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -379,7 +379,13 @@ impl TimelineKind {
|
||||
},
|
||||
|p| {
|
||||
p.parse_token("hashtag")?;
|
||||
Ok(TimelineKind::Hashtag(p.pull_token()?.to_string()))
|
||||
Ok(TimelineKind::Hashtag(
|
||||
p.pull_token()?
|
||||
.split_whitespace()
|
||||
.filter(|s| !s.is_empty())
|
||||
.map(|s| s.to_lowercase().to_string())
|
||||
.collect(),
|
||||
))
|
||||
},
|
||||
|p| {
|
||||
p.parse_token("search")?;
|
||||
@@ -437,12 +443,19 @@ impl TimelineKind {
|
||||
.build()]),
|
||||
|
||||
TimelineKind::Hashtag(hashtag) => {
|
||||
let url: &str = &hashtag.to_lowercase();
|
||||
FilterState::ready(vec![Filter::new()
|
||||
.kinds([1])
|
||||
.limit(filter::default_limit())
|
||||
.tags([url], 't')
|
||||
.build()])
|
||||
let filters = hashtag
|
||||
.iter()
|
||||
.filter(|tag| !tag.is_empty())
|
||||
.map(|tag| {
|
||||
Filter::new()
|
||||
.kinds([1])
|
||||
.limit(filter::default_limit())
|
||||
.tags([tag.to_lowercase().as_str()], 't')
|
||||
.build()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
FilterState::ready(filters)
|
||||
}
|
||||
|
||||
TimelineKind::Algo(algo_timeline) => match algo_timeline {
|
||||
@@ -579,7 +592,7 @@ impl TimelineKind {
|
||||
TimelineKind::Profile(_pubkey_source) => ColumnTitle::needs_db(self),
|
||||
TimelineKind::Universe => ColumnTitle::simple("Universe"),
|
||||
TimelineKind::Generic(_) => ColumnTitle::simple("Custom"),
|
||||
TimelineKind::Hashtag(hashtag) => ColumnTitle::formatted(hashtag.to_string()),
|
||||
TimelineKind::Hashtag(hashtag) => ColumnTitle::formatted(hashtag.join(" ").to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,18 +226,22 @@ impl Timeline {
|
||||
))
|
||||
}
|
||||
|
||||
pub fn hashtag(hashtag: String) -> Self {
|
||||
let hashtag = hashtag.to_lowercase();
|
||||
let htag: &str = &hashtag;
|
||||
let filter = Filter::new()
|
||||
.kinds([1])
|
||||
.limit(filter::default_limit())
|
||||
.tags([htag], 't')
|
||||
.build();
|
||||
pub fn hashtag(hashtag: Vec<String>) -> Self {
|
||||
let filters = hashtag
|
||||
.iter()
|
||||
.filter(|tag| !tag.is_empty())
|
||||
.map(|tag| {
|
||||
Filter::new()
|
||||
.kinds([1])
|
||||
.limit(filter::default_limit())
|
||||
.tags([tag.as_str()], 't')
|
||||
.build()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Timeline::new(
|
||||
TimelineKind::Hashtag(hashtag),
|
||||
FilterState::ready(vec![filter]),
|
||||
FilterState::ready(filters),
|
||||
TimelineTab::only_notes_and_replies(),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user