mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-18 00:54:21 +01:00
Merge contact list fixes by kernel #998
kernelkind (2):
appease clippy
fix: sometimes most recent contacts list wasn't used
This commit is contained in:
@@ -15,6 +15,7 @@ pub enum ContactState {
|
||||
Received {
|
||||
contacts: HashSet<Pubkey>,
|
||||
note_key: NoteKey,
|
||||
timestamp: u64,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -57,6 +58,7 @@ impl Contacts {
|
||||
ContactState::Received {
|
||||
contacts,
|
||||
note_key: _,
|
||||
timestamp: _,
|
||||
} => {
|
||||
if contacts.contains(other_pubkey) {
|
||||
IsFollowing::Yes
|
||||
@@ -82,6 +84,18 @@ impl Contacts {
|
||||
}
|
||||
};
|
||||
|
||||
if let ContactState::Received {
|
||||
contacts: _,
|
||||
note_key: _,
|
||||
timestamp,
|
||||
} = self.get_state()
|
||||
{
|
||||
if *timestamp > note.created_at() {
|
||||
// the current contact list is more up to date than the one we just received. ignore it.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
update_state(&mut self.state, ¬e, *key);
|
||||
}
|
||||
|
||||
@@ -96,11 +110,17 @@ fn update_state(state: &mut ContactState, note: &Note, key: NoteKey) {
|
||||
*state = ContactState::Received {
|
||||
contacts: get_contacts_owned(note),
|
||||
note_key: key,
|
||||
timestamp: note.created_at(),
|
||||
};
|
||||
}
|
||||
ContactState::Received { contacts, note_key } => {
|
||||
ContactState::Received {
|
||||
contacts,
|
||||
note_key,
|
||||
timestamp,
|
||||
} => {
|
||||
update_contacts(contacts, note);
|
||||
*note_key = key;
|
||||
*timestamp = note.created_at();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -144,6 +144,7 @@ fn send_kind_3_event(ndb: &Ndb, pool: &mut RelayPool, accounts: &Accounts, actio
|
||||
let ContactState::Received {
|
||||
contacts: _,
|
||||
note_key,
|
||||
timestamp: _,
|
||||
} = accounts.get_selected_account().data.contacts.get_state()
|
||||
else {
|
||||
return;
|
||||
|
||||
@@ -607,6 +607,7 @@ pub fn fetch_contact_list(
|
||||
ContactState::Received {
|
||||
contacts: _,
|
||||
note_key: _,
|
||||
timestamp: _,
|
||||
} => FilterState::GotRemote(filter::GotRemoteType::Contact),
|
||||
};
|
||||
|
||||
@@ -726,6 +727,7 @@ pub fn is_timeline_ready(
|
||||
let ContactState::Received {
|
||||
contacts: _,
|
||||
note_key,
|
||||
timestamp: _,
|
||||
} = accounts.get_selected_account().data.contacts.get_state()
|
||||
else {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user