Merge remote-tracking branches 'github/pr/87{0,1,2}'

Merge a few bug fixes and lint issues

Fernando López Guevara (1):
      fix: skip blurring for user's own images

William Casarin (3):
      clippy: fix large enum.

kernelkind (1):
      bugfix: txn failed
This commit is contained in:
William Casarin
2025-06-02 10:34:27 -07:00
5 changed files with 25 additions and 19 deletions

View File

@@ -123,8 +123,8 @@ impl From<NoteAction> for RenderNavAction {
} }
enum NotedeckNavResponse { enum NotedeckNavResponse {
Popup(PopupResponse<Option<RenderNavAction>>), Popup(Box<PopupResponse<Option<RenderNavAction>>>),
Nav(NavResponse<Option<RenderNavAction>>), Nav(Box<NavResponse<Option<RenderNavAction>>>),
} }
pub struct RenderNavResponse { pub struct RenderNavResponse {
@@ -147,11 +147,11 @@ impl RenderNavResponse {
) -> bool { ) -> bool {
match self.response { match self.response {
NotedeckNavResponse::Popup(nav_action) => { NotedeckNavResponse::Popup(nav_action) => {
process_popup_resp(nav_action, app, ctx, ui, self.column); process_popup_resp(*nav_action, app, ctx, ui, self.column);
false false
} }
NotedeckNavResponse::Nav(nav_response) => { NotedeckNavResponse::Nav(nav_response) => {
process_nav_resp(app, ctx, ui, nav_response, self.column) process_nav_resp(app, ctx, ui, *nav_response, self.column)
} }
} }
} }
@@ -748,7 +748,7 @@ pub fn render_nav(
NavUiType::Body => render_nav_body(ui, app, ctx, route, 1, col, inner_rect), NavUiType::Body => render_nav_body(ui, app, ctx, route, 1, col, inner_rect),
}); });
return RenderNavResponse::new(col, NotedeckNavResponse::Popup(resp)); return RenderNavResponse::new(col, NotedeckNavResponse::Popup(Box::new(resp)));
} }
}; };
@@ -790,5 +790,5 @@ pub fn render_nav(
} }
}); });
RenderNavResponse::new(col, NotedeckNavResponse::Nav(nav_response)) RenderNavResponse::new(col, NotedeckNavResponse::Nav(Box::new(nav_response)))
} }

View File

@@ -482,6 +482,7 @@ pub fn merge_sorted_vecs<T: Ord + Copy>(vec1: &[T], vec2: &[T]) -> (Vec<T>, Merg
pub fn setup_new_timeline( pub fn setup_new_timeline(
timeline: &mut Timeline, timeline: &mut Timeline,
ndb: &Ndb, ndb: &Ndb,
txn: &Transaction,
subs: &mut Subscriptions, subs: &mut Subscriptions,
pool: &mut RelayPool, pool: &mut RelayPool,
note_cache: &mut NoteCache, note_cache: &mut NoteCache,
@@ -489,7 +490,7 @@ pub fn setup_new_timeline(
) { ) {
// if we're ready, setup local subs // if we're ready, setup local subs
if is_timeline_ready(ndb, pool, note_cache, timeline) { if is_timeline_ready(ndb, pool, note_cache, timeline) {
if let Err(err) = setup_timeline_nostrdb_sub(ndb, note_cache, timeline) { if let Err(err) = setup_timeline_nostrdb_sub(ndb, txn, note_cache, timeline) {
error!("setup_new_timeline: {err}"); error!("setup_new_timeline: {err}");
} }
} }
@@ -616,6 +617,7 @@ fn fetch_contact_list(
fn setup_initial_timeline( fn setup_initial_timeline(
ndb: &Ndb, ndb: &Ndb,
txn: &Transaction,
timeline: &mut Timeline, timeline: &mut Timeline,
note_cache: &mut NoteCache, note_cache: &mut NoteCache,
filters: &[Filter], filters: &[Filter],
@@ -647,14 +649,13 @@ fn setup_initial_timeline(
lim += filter.limit().unwrap_or(1) as i32; lim += filter.limit().unwrap_or(1) as i32;
} }
let txn = Transaction::new(ndb)?;
let notes: Vec<NoteRef> = ndb let notes: Vec<NoteRef> = ndb
.query(&txn, filters, lim)? .query(txn, filters, lim)?
.into_iter() .into_iter()
.map(NoteRef::from_query_result) .map(NoteRef::from_query_result)
.collect(); .collect();
timeline.insert_new(&txn, ndb, note_cache, &notes); timeline.insert_new(txn, ndb, note_cache, &notes);
Ok(()) Ok(())
} }
@@ -665,7 +666,8 @@ pub fn setup_initial_nostrdb_subs(
timeline_cache: &mut TimelineCache, timeline_cache: &mut TimelineCache,
) -> Result<()> { ) -> Result<()> {
for (_kind, timeline) in timeline_cache.timelines.iter_mut() { for (_kind, timeline) in timeline_cache.timelines.iter_mut() {
if let Err(err) = setup_timeline_nostrdb_sub(ndb, note_cache, timeline) { let txn = Transaction::new(ndb).expect("txn");
if let Err(err) = setup_timeline_nostrdb_sub(ndb, &txn, note_cache, timeline) {
error!("setup_initial_nostrdb_subs: {err}"); error!("setup_initial_nostrdb_subs: {err}");
} }
} }
@@ -675,6 +677,7 @@ pub fn setup_initial_nostrdb_subs(
fn setup_timeline_nostrdb_sub( fn setup_timeline_nostrdb_sub(
ndb: &Ndb, ndb: &Ndb,
txn: &Transaction,
note_cache: &mut NoteCache, note_cache: &mut NoteCache,
timeline: &mut Timeline, timeline: &mut Timeline,
) -> Result<()> { ) -> Result<()> {
@@ -684,7 +687,7 @@ fn setup_timeline_nostrdb_sub(
.ok_or(Error::App(notedeck::Error::empty_contact_list()))? .ok_or(Error::App(notedeck::Error::empty_contact_list()))?
.to_owned(); .to_owned();
setup_initial_timeline(ndb, timeline, note_cache, &filter_state)?; setup_initial_timeline(ndb, txn, timeline, note_cache, &filter_state)?;
Ok(()) Ok(())
} }
@@ -754,7 +757,8 @@ pub fn is_timeline_ready(
// we just switched to the ready state, we should send initial // we just switched to the ready state, we should send initial
// queries and setup the local subscription // queries and setup the local subscription
info!("Found contact list! Setting up local and remote contact list query"); info!("Found contact list! Setting up local and remote contact list query");
setup_initial_timeline(ndb, timeline, note_cache, &filter).expect("setup init"); let txn = Transaction::new(ndb).expect("txn");
setup_initial_timeline(ndb, &txn, timeline, note_cache, &filter).expect("setup init");
timeline timeline
.filter .filter
.set_relay_state(relay_id, FilterState::ready(filter.clone())); .set_relay_state(relay_id, FilterState::ready(filter.clone()));

View File

@@ -637,6 +637,7 @@ pub fn render_add_column_routes(
crate::timeline::setup_new_timeline( crate::timeline::setup_new_timeline(
&mut timeline, &mut timeline,
ctx.ndb, ctx.ndb,
&txn,
&mut app.subscriptions, &mut app.subscriptions,
ctx.pool, ctx.pool,
ctx.note_cache, ctx.note_cache,
@@ -669,15 +670,15 @@ pub fn render_add_column_routes(
// source to be, so let;s create a timeline from that and // source to be, so let;s create a timeline from that and
// add it to our list of timelines // add it to our list of timelines
AlgoOption::LastPerPubkey(Decision::Decided(list_kind)) => { AlgoOption::LastPerPubkey(Decision::Decided(list_kind)) => {
let maybe_timeline = { let txn = Transaction::new(ctx.ndb).unwrap();
let txn = Transaction::new(ctx.ndb).unwrap(); let maybe_timeline =
TimelineKind::last_per_pubkey(list_kind).into_timeline(&txn, ctx.ndb) TimelineKind::last_per_pubkey(list_kind).into_timeline(&txn, ctx.ndb);
};
if let Some(mut timeline) = maybe_timeline { if let Some(mut timeline) = maybe_timeline {
crate::timeline::setup_new_timeline( crate::timeline::setup_new_timeline(
&mut timeline, &mut timeline,
ctx.ndb, ctx.ndb,
&txn,
&mut app.subscriptions, &mut app.subscriptions,
ctx.pool, ctx.pool,
ctx.note_cache, ctx.note_cache,

View File

@@ -410,7 +410,8 @@ impl<'a, 'd> TimelineTabView<'a, 'd> {
let zapping_acc = self let zapping_acc = self
.cur_acc .cur_acc
.as_ref() .as_ref()
.filter(|_| self.note_context.current_account_has_wallet); .filter(|_| self.note_context.current_account_has_wallet)
.or(self.cur_acc.as_ref());
notedeck_ui::padding(8.0, ui, |ui| { notedeck_ui::padding(8.0, ui, |ui| {
let resp = NoteView::new( let resp = NoteView::new(

View File

@@ -17,7 +17,7 @@ pub fn trust_media_from_pk2(
pk1: Option<&[u8; 32]>, pk1: Option<&[u8; 32]>,
pk2: &[u8; 32], pk2: &[u8; 32],
) -> bool { ) -> bool {
pk1.map(|pk| pk1_is_following_pk2(ndb, txn, pk, pk2).unwrap_or(false)) pk1.map(|pk| pk == pk2 || pk1_is_following_pk2(ndb, txn, pk, pk2).unwrap_or(false))
.unwrap_or(false) .unwrap_or(false)
} }