fix contact list bug

not a great solution but we're going to get a new sub manager
soon so it'll probably get replaced anyway

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-08-17 14:56:28 -04:00
parent 1566cd5cf4
commit 9ef72ec7de
4 changed files with 43 additions and 14 deletions

View File

@@ -86,6 +86,13 @@ impl FilterStates {
} }
self.states.insert(relay, state); self.states.insert(relay, state);
} }
/// For contacts, since that sub is managed elsewhere
pub fn set_all_states(&mut self, state: FilterState) {
for cur_state in self.states.values_mut() {
*cur_state = state.clone();
}
}
} }
/// We may need to fetch some data from relays before our filter is ready. /// We may need to fetch some data from relays before our filter is ready.

View File

@@ -145,7 +145,7 @@ fn try_process_event(
} }
} }
for (_kind, timeline) in &mut damus.timeline_cache { for (kind, timeline) in &mut damus.timeline_cache {
let is_ready = timeline::is_timeline_ready( let is_ready = timeline::is_timeline_ready(
app_ctx.ndb, app_ctx.ndb,
app_ctx.pool, app_ctx.pool,
@@ -170,6 +170,9 @@ fn try_process_event(
} }
} else { } else {
// TODO: show loading? // TODO: show loading?
if matches!(kind, TimelineKind::List(ListKind::Contact(_))) {
timeline::fetch_contact_list(&mut damus.subscriptions, timeline, app_ctx.accounts);
}
} }
} }
@@ -881,7 +884,13 @@ fn timelines_view(
let mut save_cols = false; let mut save_cols = false;
if let Some(action) = side_panel_action { if let Some(action) = side_panel_action {
save_cols = save_cols save_cols = save_cols
|| action.process(&mut app.timeline_cache, &mut app.decks_cache, ctx, ui.ctx()); || action.process(
&mut app.timeline_cache,
&mut app.decks_cache,
ctx,
&mut app.subscriptions,
ui.ctx(),
);
} }
let mut app_action: Option<AppAction> = None; let mut app_action: Option<AppAction> = None;

View File

@@ -8,7 +8,9 @@ use crate::{
options::AppOptions, options::AppOptions,
profile::{ProfileAction, SaveProfileChanges}, profile::{ProfileAction, SaveProfileChanges},
route::{Route, Router, SingletonRouter}, route::{Route, Router, SingletonRouter},
subscriptions::Subscriptions,
timeline::{ timeline::{
kind::ListKind,
route::{render_thread_route, render_timeline_route}, route::{render_thread_route, render_timeline_route},
TimelineCache, TimelineKind, TimelineCache, TimelineKind,
}, },
@@ -81,6 +83,7 @@ impl SwitchingAction {
timeline_cache: &mut TimelineCache, timeline_cache: &mut TimelineCache,
decks_cache: &mut DecksCache, decks_cache: &mut DecksCache,
ctx: &mut AppContext<'_>, ctx: &mut AppContext<'_>,
subs: &mut Subscriptions,
ui_ctx: &egui::Context, ui_ctx: &egui::Context,
) -> bool { ) -> bool {
match &self { match &self {
@@ -95,6 +98,15 @@ impl SwitchingAction {
ctx.pool, ctx.pool,
ui_ctx, ui_ctx,
); );
let contacts_sub = ctx.accounts.get_subs().contacts.remote.clone();
// this is cringe but we're gonna get a new sub manager soon...
subs.subs.insert(
contacts_sub,
crate::subscriptions::SubKind::FetchingContactList(TimelineKind::List(
ListKind::Contact(*ctx.accounts.selected_account_pubkey()),
)),
);
} }
if switch_action.switching_to_new { if switch_action.switching_to_new {
@@ -476,6 +488,7 @@ fn process_render_nav_action(
&mut app.timeline_cache, &mut app.timeline_cache,
&mut app.decks_cache, &mut app.decks_cache,
ctx, ctx,
&mut app.subscriptions,
ui.ctx(), ui.ctx(),
) { ) {
return Some(ProcessNavResult::SwitchOccurred); return Some(ProcessNavResult::SwitchOccurred);

View File

@@ -593,18 +593,14 @@ pub fn send_initial_timeline_filter(
} }
// we need some data first // we need some data first
FilterState::NeedsRemote => fetch_contact_list(subs, relay, timeline, accounts), FilterState::NeedsRemote => fetch_contact_list(subs, timeline, accounts),
} }
} }
pub fn fetch_contact_list( pub fn fetch_contact_list(subs: &mut Subscriptions, timeline: &mut Timeline, accounts: &Accounts) {
subs: &mut Subscriptions, if timeline.filter.get_any_ready().is_some() {
relay: &mut PoolRelay, return;
timeline: &mut Timeline, }
accounts: &Accounts,
) {
let sub_kind = SubKind::FetchingContactList(timeline.kind.clone());
let sub = &accounts.get_subs().contacts;
let new_filter_state = match accounts.get_selected_account().data.contacts.get_state() { let new_filter_state = match accounts.get_selected_account().data.contacts.get_state() {
ContactState::Unreceived => { ContactState::Unreceived => {
@@ -617,10 +613,14 @@ pub fn fetch_contact_list(
} => FilterState::GotRemote(filter::GotRemoteType::Contact), } => FilterState::GotRemote(filter::GotRemoteType::Contact),
}; };
timeline timeline.filter.set_all_states(new_filter_state);
.filter
.set_relay_state(relay.url().to_string(), new_filter_state);
let sub = &accounts.get_subs().contacts;
if subs.subs.contains_key(&sub.remote) {
return;
}
let sub_kind = SubKind::FetchingContactList(timeline.kind.clone());
subs.subs.insert(sub.remote.clone(), sub_kind); subs.subs.insert(sub.remote.clone(), sub_kind);
} }