mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-18 17:14:21 +01:00
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:
@@ -86,6 +86,13 @@ impl FilterStates {
|
||||
}
|
||||
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.
|
||||
|
||||
@@ -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(
|
||||
app_ctx.ndb,
|
||||
app_ctx.pool,
|
||||
@@ -170,6 +170,9 @@ fn try_process_event(
|
||||
}
|
||||
} else {
|
||||
// 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;
|
||||
if let Some(action) = side_panel_action {
|
||||
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;
|
||||
|
||||
@@ -8,7 +8,9 @@ use crate::{
|
||||
options::AppOptions,
|
||||
profile::{ProfileAction, SaveProfileChanges},
|
||||
route::{Route, Router, SingletonRouter},
|
||||
subscriptions::Subscriptions,
|
||||
timeline::{
|
||||
kind::ListKind,
|
||||
route::{render_thread_route, render_timeline_route},
|
||||
TimelineCache, TimelineKind,
|
||||
},
|
||||
@@ -81,6 +83,7 @@ impl SwitchingAction {
|
||||
timeline_cache: &mut TimelineCache,
|
||||
decks_cache: &mut DecksCache,
|
||||
ctx: &mut AppContext<'_>,
|
||||
subs: &mut Subscriptions,
|
||||
ui_ctx: &egui::Context,
|
||||
) -> bool {
|
||||
match &self {
|
||||
@@ -95,6 +98,15 @@ impl SwitchingAction {
|
||||
ctx.pool,
|
||||
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 {
|
||||
@@ -476,6 +488,7 @@ fn process_render_nav_action(
|
||||
&mut app.timeline_cache,
|
||||
&mut app.decks_cache,
|
||||
ctx,
|
||||
&mut app.subscriptions,
|
||||
ui.ctx(),
|
||||
) {
|
||||
return Some(ProcessNavResult::SwitchOccurred);
|
||||
|
||||
@@ -593,18 +593,14 @@ 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, timeline, accounts),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fetch_contact_list(
|
||||
subs: &mut Subscriptions,
|
||||
relay: &mut PoolRelay,
|
||||
timeline: &mut Timeline,
|
||||
accounts: &Accounts,
|
||||
) {
|
||||
let sub_kind = SubKind::FetchingContactList(timeline.kind.clone());
|
||||
let sub = &accounts.get_subs().contacts;
|
||||
pub fn fetch_contact_list(subs: &mut Subscriptions, timeline: &mut Timeline, accounts: &Accounts) {
|
||||
if timeline.filter.get_any_ready().is_some() {
|
||||
return;
|
||||
}
|
||||
|
||||
let new_filter_state = match accounts.get_selected_account().data.contacts.get_state() {
|
||||
ContactState::Unreceived => {
|
||||
@@ -617,10 +613,14 @@ pub fn fetch_contact_list(
|
||||
} => FilterState::GotRemote(filter::GotRemoteType::Contact),
|
||||
};
|
||||
|
||||
timeline
|
||||
.filter
|
||||
.set_relay_state(relay.url().to_string(), new_filter_state);
|
||||
timeline.filter.set_all_states(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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user