mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-18 17:14:21 +01:00
remove unnecessary FilterState::NeedsRemote filter
all NeedsRemote states are contact lists currently, which is managed by `Accounts` Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -92,7 +92,7 @@ impl FilterStates {
|
||||
/// [`FilterState`] tracks this.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum FilterState {
|
||||
NeedsRemote(Vec<Filter>),
|
||||
NeedsRemote,
|
||||
FetchingRemote(FetchingRemoteType),
|
||||
GotRemote(GotRemoteType),
|
||||
Ready(Vec<Filter>),
|
||||
@@ -139,8 +139,8 @@ impl FilterState {
|
||||
/// for home timelines where we don't have a contact list yet. We
|
||||
/// need to fetch the contact list before we have the right timeline
|
||||
/// filter.
|
||||
pub fn needs_remote(filter: Vec<Filter>) -> Self {
|
||||
Self::NeedsRemote(filter)
|
||||
pub fn needs_remote() -> Self {
|
||||
Self::NeedsRemote
|
||||
}
|
||||
|
||||
/// We got the remote data. Local data should be available to build
|
||||
|
||||
@@ -500,11 +500,7 @@ impl TimelineKind {
|
||||
}
|
||||
|
||||
TimelineKind::Algo(AlgoTimeline::LastPerPubkey(ListKind::Contact(pk))) => {
|
||||
let contact_filter = Filter::new()
|
||||
.authors([pk.bytes()])
|
||||
.kinds([3])
|
||||
.limit(1)
|
||||
.build();
|
||||
let contact_filter = contacts_filter(pk.bytes());
|
||||
|
||||
let results = ndb
|
||||
.query(txn, &[contact_filter.clone()], 1)
|
||||
@@ -516,7 +512,7 @@ impl TimelineKind {
|
||||
if results.is_empty() {
|
||||
return Some(Timeline::new(
|
||||
kind_fn(ListKind::contact_list(pk)),
|
||||
FilterState::needs_remote(vec![contact_filter.clone()]),
|
||||
FilterState::needs_remote(),
|
||||
tabs,
|
||||
));
|
||||
}
|
||||
@@ -527,7 +523,7 @@ impl TimelineKind {
|
||||
Err(Error::App(notedeck::Error::Filter(FilterError::EmptyContactList))) => {
|
||||
Some(Timeline::new(
|
||||
kind_fn(list_kind),
|
||||
FilterState::needs_remote(vec![contact_filter]),
|
||||
FilterState::needs_remote(),
|
||||
tabs,
|
||||
))
|
||||
}
|
||||
@@ -652,12 +648,12 @@ fn contact_filter_state(txn: &Transaction, ndb: &Ndb, pk: &Pubkey) -> FilterStat
|
||||
.expect("contact query failed?");
|
||||
|
||||
if results.is_empty() {
|
||||
FilterState::needs_remote(vec![contact_filter.clone()])
|
||||
FilterState::needs_remote()
|
||||
} else {
|
||||
let with_hashtags = false;
|
||||
match filter::filter_from_tags(&results[0].note, Some(pk.bytes()), with_hashtags) {
|
||||
Err(notedeck::Error::Filter(FilterError::EmptyContactList)) => {
|
||||
FilterState::needs_remote(vec![contact_filter])
|
||||
FilterState::needs_remote()
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Error getting contact filter state: {err}");
|
||||
@@ -669,11 +665,7 @@ fn contact_filter_state(txn: &Transaction, ndb: &Ndb, pk: &Pubkey) -> FilterStat
|
||||
}
|
||||
|
||||
fn last_per_pubkey_filter_state(ndb: &Ndb, pk: &Pubkey) -> FilterState {
|
||||
let contact_filter = Filter::new()
|
||||
.authors([pk.bytes()])
|
||||
.kinds([3])
|
||||
.limit(1)
|
||||
.build();
|
||||
let contact_filter = contacts_filter(pk.bytes());
|
||||
|
||||
let txn = Transaction::new(ndb).expect("txn");
|
||||
let results = ndb
|
||||
@@ -681,13 +673,13 @@ fn last_per_pubkey_filter_state(ndb: &Ndb, pk: &Pubkey) -> FilterState {
|
||||
.expect("contact query failed?");
|
||||
|
||||
if results.is_empty() {
|
||||
FilterState::needs_remote(vec![contact_filter])
|
||||
FilterState::needs_remote()
|
||||
} else {
|
||||
let kind = 1;
|
||||
let notes_per_pk = 1;
|
||||
match filter::last_n_per_pubkey_from_tags(&results[0].note, kind, notes_per_pk) {
|
||||
Err(notedeck::Error::Filter(FilterError::EmptyContactList)) => {
|
||||
FilterState::needs_remote(vec![contact_filter])
|
||||
FilterState::needs_remote()
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Error getting contact filter state: {err}");
|
||||
|
||||
@@ -574,7 +574,7 @@ pub fn send_initial_timeline_filter(
|
||||
}
|
||||
|
||||
// we need some data first
|
||||
FilterState::NeedsRemote(_) => fetch_contact_list(subs, relay, timeline, accounts),
|
||||
FilterState::NeedsRemote => fetch_contact_list(subs, relay, timeline, accounts),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user