use Contacts in AccountData
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::account::cache::AccountCache;
|
use crate::account::cache::AccountCache;
|
||||||
|
use crate::account::contacts::Contacts;
|
||||||
use crate::account::mute::AccountMutedData;
|
use crate::account::mute::AccountMutedData;
|
||||||
use crate::account::relay::{
|
use crate::account::relay::{
|
||||||
modify_advertised_relays, update_relay_configuration, AccountRelayData, RelayAction,
|
modify_advertised_relays, update_relay_configuration, AccountRelayData, RelayAction,
|
||||||
@@ -253,6 +254,13 @@ impl Accounts {
|
|||||||
),
|
),
|
||||||
relay_url,
|
relay_url,
|
||||||
);
|
);
|
||||||
|
pool.send_to(
|
||||||
|
&ClientMessage::req(
|
||||||
|
self.subs.contacts.remote.clone(),
|
||||||
|
vec![data.contacts.filter.clone()],
|
||||||
|
),
|
||||||
|
relay_url,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, ndb: &mut Ndb, pool: &mut RelayPool, ctx: &egui::Context) {
|
pub fn update(&mut self, ndb: &mut Ndb, pool: &mut RelayPool, ctx: &egui::Context) {
|
||||||
@@ -366,6 +374,7 @@ fn get_acc_from_storage(user_account_serializable: UserAccountSerializable) -> O
|
|||||||
pub struct AccountData {
|
pub struct AccountData {
|
||||||
pub(crate) relay: AccountRelayData,
|
pub(crate) relay: AccountRelayData,
|
||||||
pub(crate) muted: AccountMutedData,
|
pub(crate) muted: AccountMutedData,
|
||||||
|
pub contacts: Contacts,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AccountData {
|
impl AccountData {
|
||||||
@@ -373,6 +382,7 @@ impl AccountData {
|
|||||||
Self {
|
Self {
|
||||||
relay: AccountRelayData::new(pubkey),
|
relay: AccountRelayData::new(pubkey),
|
||||||
muted: AccountMutedData::new(pubkey),
|
muted: AccountMutedData::new(pubkey),
|
||||||
|
contacts: Contacts::new(pubkey),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,6 +398,8 @@ impl AccountData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.muted.poll_for_updates(ndb, &txn, subs.mute.local);
|
self.muted.poll_for_updates(ndb, &txn, subs.mute.local);
|
||||||
|
self.contacts
|
||||||
|
.poll_for_updates(ndb, &txn, subs.contacts.local);
|
||||||
|
|
||||||
resp
|
resp
|
||||||
}
|
}
|
||||||
@@ -396,6 +408,7 @@ impl AccountData {
|
|||||||
pub(super) fn query(&mut self, ndb: &Ndb, txn: &Transaction) {
|
pub(super) fn query(&mut self, ndb: &Ndb, txn: &Transaction) {
|
||||||
self.relay.query(ndb, txn);
|
self.relay.query(ndb, txn);
|
||||||
self.muted.query(ndb, txn);
|
self.muted.query(ndb, txn);
|
||||||
|
self.contacts.query(ndb, txn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,6 +424,7 @@ pub struct AddAccountResponse {
|
|||||||
pub(super) struct AccountSubs {
|
pub(super) struct AccountSubs {
|
||||||
relay: UnifiedSubscription,
|
relay: UnifiedSubscription,
|
||||||
mute: UnifiedSubscription,
|
mute: UnifiedSubscription,
|
||||||
|
contacts: UnifiedSubscription,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AccountSubs {
|
impl AccountSubs {
|
||||||
@@ -424,9 +438,14 @@ impl AccountSubs {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
let relay = subscribe(ndb, pool, &data.relay.filter);
|
let relay = subscribe(ndb, pool, &data.relay.filter);
|
||||||
let mute = subscribe(ndb, pool, &data.muted.filter);
|
let mute = subscribe(ndb, pool, &data.muted.filter);
|
||||||
|
let contacts = subscribe(ndb, pool, &data.contacts.filter);
|
||||||
update_relay_configuration(pool, relay_defaults, pk, &data.relay, wakeup);
|
update_relay_configuration(pool, relay_defaults, pk, &data.relay, wakeup);
|
||||||
|
|
||||||
Self { relay, mute }
|
Self {
|
||||||
|
relay,
|
||||||
|
mute,
|
||||||
|
contacts,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn swap_to(
|
pub fn swap_to(
|
||||||
@@ -440,6 +459,7 @@ impl AccountSubs {
|
|||||||
) {
|
) {
|
||||||
unsubscribe(ndb, pool, &self.relay);
|
unsubscribe(ndb, pool, &self.relay);
|
||||||
unsubscribe(ndb, pool, &self.mute);
|
unsubscribe(ndb, pool, &self.mute);
|
||||||
|
unsubscribe(ndb, pool, &self.contacts);
|
||||||
|
|
||||||
*self = AccountSubs::new(ndb, pool, relay_defaults, pk, new_selection_data, wakeup);
|
*self = AccountSubs::new(ndb, pool, relay_defaults, pk, new_selection_data, wakeup);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use enostr::{Keypair, KeypairUnowned};
|
use enostr::{Keypair, KeypairUnowned, Pubkey};
|
||||||
use tokenator::{ParseError, TokenParser, TokenSerializable};
|
use tokenator::{ParseError, TokenParser, TokenSerializable};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
wallet::{WalletSerializable, ZapWallet},
|
wallet::{WalletSerializable, ZapWallet},
|
||||||
AccountData,
|
AccountData, IsFollowing,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct UserAccount {
|
pub struct UserAccount {
|
||||||
@@ -32,6 +32,10 @@ impl UserAccount {
|
|||||||
self.wallet = Some(wallet);
|
self.wallet = Some(wallet);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_following(&self, pk: &Pubkey) -> IsFollowing {
|
||||||
|
self.data.contacts.is_following(pk)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UserAccountSerializable {
|
pub struct UserAccountSerializable {
|
||||||
|
|||||||
Reference in New Issue
Block a user