remove duplicate filter types
only use nostrdb::Filter Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -6,7 +6,8 @@ use crate::{
|
||||
};
|
||||
use enostr::NoteId;
|
||||
use nostrdb::Transaction;
|
||||
use tracing::{info, warn};
|
||||
use tracing::{error, info};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
|
||||
pub enum BarAction {
|
||||
@@ -45,11 +46,11 @@ fn open_thread(
|
||||
let root_id = crate::note::root_note_id_from_selected_id(app, txn, selected_note);
|
||||
let thread_res = app.threads.thread_mut(&app.ndb, txn, root_id);
|
||||
|
||||
// The thread is stale, let's update it
|
||||
let (thread, result) = match thread_res {
|
||||
ThreadResult::Stale(thread) => {
|
||||
// The thread is stale, let's update it
|
||||
let notes = Thread::new_notes(&thread.view.notes, root_id, txn, &app.ndb);
|
||||
let br = if notes.is_empty() {
|
||||
let bar_result = if notes.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(BarResult::new_thread_notes(
|
||||
@@ -63,8 +64,9 @@ fn open_thread(
|
||||
// are already borrowing it mutably. Let's pass it as a
|
||||
// result instead
|
||||
//
|
||||
// thread.view.insert(¬es);
|
||||
(thread, br)
|
||||
// thread.view.insert(¬es); <-- no
|
||||
//
|
||||
(thread, bar_result)
|
||||
}
|
||||
|
||||
ThreadResult::Fresh(thread) => (thread, None),
|
||||
@@ -73,18 +75,27 @@ fn open_thread(
|
||||
// only start a subscription on nav and if we don't have
|
||||
// an active subscription for this thread.
|
||||
if thread.subscription().is_none() {
|
||||
*thread.subscription_mut() = app.ndb.subscribe(Thread::filters(root_id)).ok();
|
||||
let filters = Thread::filters(root_id);
|
||||
*thread.subscription_mut() = app.ndb.subscribe(filters.clone()).ok();
|
||||
|
||||
if thread.remote_subscription().is_some() {
|
||||
error!("Found active remote subscription when it was not expected");
|
||||
} else {
|
||||
let subid = Uuid::new_v4().to_string();
|
||||
*thread.remote_subscription_mut() = Some(subid.clone());
|
||||
app.pool.subscribe(subid, filters);
|
||||
}
|
||||
|
||||
match thread.subscription() {
|
||||
Some(_sub) => {
|
||||
thread.subscribers += 1;
|
||||
info!(
|
||||
"Locally subscribing to thread. {} total active subscriptions, {} on this thread",
|
||||
"Locally/remotely subscribing to thread. {} total active subscriptions, {} on this thread",
|
||||
app.ndb.subscription_count(),
|
||||
thread.subscribers,
|
||||
);
|
||||
}
|
||||
None => warn!(
|
||||
None => error!(
|
||||
"Error subscribing locally to selected note '{}''s thread",
|
||||
hex::encode(selected_note)
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user