propagate JobsCache

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-04-18 22:48:57 -05:00
parent e6212e5d17
commit a29277d263
15 changed files with 153 additions and 42 deletions

View File

@@ -14,6 +14,7 @@ use egui::{
};
use enostr::{FilledKeypair, FullKeypair, NoteId, Pubkey, RelayPool};
use nostrdb::{Ndb, Transaction};
use notedeck_ui::jobs::JobsCache;
use notedeck_ui::{
gif::{handle_repaint, retrieve_latest_texture},
images::render_images,
@@ -32,6 +33,7 @@ pub struct PostView<'a, 'd> {
id_source: Option<egui::Id>,
inner_rect: egui::Rect,
note_options: NoteOptions,
jobs: &'a mut JobsCache,
}
#[derive(Clone)]
@@ -103,6 +105,7 @@ impl<'a, 'd> PostView<'a, 'd> {
poster: FilledKeypair<'a>,
inner_rect: egui::Rect,
note_options: NoteOptions,
jobs: &'a mut JobsCache,
) -> Self {
let id_source: Option<egui::Id> = None;
PostView {
@@ -113,6 +116,7 @@ impl<'a, 'd> PostView<'a, 'd> {
post_type,
inner_rect,
note_options,
jobs,
}
}
@@ -345,6 +349,7 @@ impl<'a, 'd> PostView<'a, 'd> {
id.bytes(),
nostrdb::NoteKey::new(0),
self.note_options,
self.jobs,
)
})
.inner
@@ -696,6 +701,7 @@ mod preview {
pub struct PostPreview {
draft: Draft,
poster: FullKeypair,
jobs: JobsCache,
}
impl PostPreview {
@@ -725,6 +731,7 @@ mod preview {
PostPreview {
draft,
poster: FullKeypair::generate(),
jobs: Default::default(),
}
}
}
@@ -738,6 +745,7 @@ mod preview {
note_cache: app.note_cache,
zaps: app.zaps,
pool: app.pool,
job_pool: app.job_pool,
};
PostView::new(
@@ -747,6 +755,7 @@ mod preview {
self.poster.to_filled(),
ui.available_rect_before_wrap(),
NoteOptions::default(),
&mut self.jobs,
)
.ui(&txn, ui);

View File

@@ -6,7 +6,7 @@ use crate::{
use enostr::{FilledKeypair, NoteId};
use notedeck::NoteContext;
use notedeck_ui::NoteOptions;
use notedeck_ui::{jobs::JobsCache, NoteOptions};
pub struct QuoteRepostView<'a, 'd> {
note_context: &'a mut NoteContext<'d>,
@@ -16,6 +16,7 @@ pub struct QuoteRepostView<'a, 'd> {
id_source: Option<egui::Id>,
inner_rect: egui::Rect,
note_options: NoteOptions,
jobs: &'a mut JobsCache,
}
impl<'a, 'd> QuoteRepostView<'a, 'd> {
@@ -27,6 +28,7 @@ impl<'a, 'd> QuoteRepostView<'a, 'd> {
quoting_note: &'a nostrdb::Note<'a>,
inner_rect: egui::Rect,
note_options: NoteOptions,
jobs: &'a mut JobsCache,
) -> Self {
let id_source: Option<egui::Id> = None;
QuoteRepostView {
@@ -37,6 +39,7 @@ impl<'a, 'd> QuoteRepostView<'a, 'd> {
id_source,
inner_rect,
note_options,
jobs,
}
}
@@ -51,6 +54,7 @@ impl<'a, 'd> QuoteRepostView<'a, 'd> {
self.poster,
self.inner_rect,
self.note_options,
self.jobs,
)
.id_source(id)
.ui(self.quoting_note.txn().unwrap(), ui);

View File

@@ -6,6 +6,7 @@ use crate::ui::{
use enostr::{FilledKeypair, NoteId};
use notedeck::NoteContext;
use notedeck_ui::jobs::JobsCache;
use notedeck_ui::{NoteOptions, NoteView, ProfilePic};
pub struct PostReplyView<'a, 'd> {
@@ -16,6 +17,7 @@ pub struct PostReplyView<'a, 'd> {
id_source: Option<egui::Id>,
inner_rect: egui::Rect,
note_options: NoteOptions,
jobs: &'a mut JobsCache,
}
impl<'a, 'd> PostReplyView<'a, 'd> {
@@ -27,6 +29,7 @@ impl<'a, 'd> PostReplyView<'a, 'd> {
note: &'a nostrdb::Note<'a>,
inner_rect: egui::Rect,
note_options: NoteOptions,
jobs: &'a mut JobsCache,
) -> Self {
let id_source: Option<egui::Id> = None;
PostReplyView {
@@ -37,6 +40,7 @@ impl<'a, 'd> PostReplyView<'a, 'd> {
id_source,
inner_rect,
note_options,
jobs,
}
}
@@ -71,6 +75,7 @@ impl<'a, 'd> PostReplyView<'a, 'd> {
&Some(self.poster.into()),
self.note,
self.note_options,
self.jobs,
)
.truncate(false)
.selectable_text(true)
@@ -93,6 +98,7 @@ impl<'a, 'd> PostReplyView<'a, 'd> {
self.poster,
self.inner_rect,
self.note_options,
self.jobs,
)
.id_source(id)
.ui(self.note.txn().unwrap(), ui)

View File

@@ -15,6 +15,7 @@ use notedeck::{
NotedeckTextStyle, UnknownIds,
};
use notedeck_ui::{
jobs::JobsCache,
profile::{about_section_widget, banner, display_name_widget},
NoteOptions, ProfilePic,
};
@@ -28,6 +29,7 @@ pub struct ProfileView<'a, 'd> {
unknown_ids: &'a mut UnknownIds,
is_muted: &'a MuteFun,
note_context: &'a mut NoteContext<'d>,
jobs: &'a mut JobsCache,
}
pub enum ProfileViewAction {
@@ -46,6 +48,7 @@ impl<'a, 'd> ProfileView<'a, 'd> {
unknown_ids: &'a mut UnknownIds,
is_muted: &'a MuteFun,
note_context: &'a mut NoteContext<'d>,
jobs: &'a mut JobsCache,
) -> Self {
ProfileView {
pubkey,
@@ -56,6 +59,7 @@ impl<'a, 'd> ProfileView<'a, 'd> {
unknown_ids,
is_muted,
note_context,
jobs,
}
}
@@ -112,6 +116,7 @@ impl<'a, 'd> ProfileView<'a, 'd> {
.accounts
.get_selected_account()
.map(|a| (&a.key).into()),
self.jobs,
)
.show(ui)
{

View File

@@ -5,7 +5,7 @@ use crate::ui::timeline::TimelineTabView;
use egui_winit::clipboard::Clipboard;
use nostrdb::{Filter, Transaction};
use notedeck::{MuteFun, NoteAction, NoteContext, NoteRef};
use notedeck_ui::{icons::search_icon, padding, NoteOptions};
use notedeck_ui::{icons::search_icon, jobs::JobsCache, padding, NoteOptions};
use std::time::{Duration, Instant};
use tracing::{error, info, warn};
@@ -20,6 +20,7 @@ pub struct SearchView<'a, 'd> {
is_muted: &'a MuteFun,
note_context: &'a mut NoteContext<'d>,
cur_acc: &'a Option<KeypairUnowned<'a>>,
jobs: &'a mut JobsCache,
}
impl<'a, 'd> SearchView<'a, 'd> {
@@ -30,6 +31,7 @@ impl<'a, 'd> SearchView<'a, 'd> {
query: &'a mut SearchQueryState,
note_context: &'a mut NoteContext<'d>,
cur_acc: &'a Option<KeypairUnowned<'a>>,
jobs: &'a mut JobsCache,
) -> Self {
Self {
txn,
@@ -38,6 +40,7 @@ impl<'a, 'd> SearchView<'a, 'd> {
note_options,
note_context,
cur_acc,
jobs,
}
}
@@ -81,6 +84,7 @@ impl<'a, 'd> SearchView<'a, 'd> {
self.is_muted,
self.note_context,
self.cur_acc,
self.jobs,
)
.show(ui)
})

View File

@@ -1,6 +1,7 @@
use enostr::KeypairUnowned;
use nostrdb::Transaction;
use notedeck::{MuteFun, NoteAction, NoteContext, RootNoteId, UnknownIds};
use notedeck_ui::jobs::JobsCache;
use notedeck_ui::NoteOptions;
use tracing::error;
@@ -16,6 +17,7 @@ pub struct ThreadView<'a, 'd> {
is_muted: &'a MuteFun,
note_context: &'a mut NoteContext<'d>,
cur_acc: &'a Option<KeypairUnowned<'a>>,
jobs: &'a mut JobsCache,
}
impl<'a, 'd> ThreadView<'a, 'd> {
@@ -28,6 +30,7 @@ impl<'a, 'd> ThreadView<'a, 'd> {
is_muted: &'a MuteFun,
note_context: &'a mut NoteContext<'d>,
cur_acc: &'a Option<KeypairUnowned<'a>>,
jobs: &'a mut JobsCache,
) -> Self {
let id_source = egui::Id::new("threadscroll_threadview");
ThreadView {
@@ -39,6 +42,7 @@ impl<'a, 'd> ThreadView<'a, 'd> {
is_muted,
note_context,
cur_acc,
jobs,
}
}
@@ -102,6 +106,7 @@ impl<'a, 'd> ThreadView<'a, 'd> {
self.is_muted,
self.note_context,
self.cur_acc,
self.jobs,
)
.show(ui)
})

View File

@@ -3,6 +3,7 @@ use egui::{vec2, Direction, Layout, Pos2, Stroke};
use egui_tabs::TabColor;
use enostr::KeypairUnowned;
use nostrdb::Transaction;
use notedeck_ui::jobs::JobsCache;
use std::f32::consts::PI;
use tracing::{error, warn};
@@ -21,6 +22,7 @@ pub struct TimelineView<'a, 'd> {
is_muted: &'a MuteFun,
note_context: &'a mut NoteContext<'d>,
cur_acc: &'a Option<KeypairUnowned<'a>>,
jobs: &'a mut JobsCache,
}
impl<'a, 'd> TimelineView<'a, 'd> {
@@ -32,6 +34,7 @@ impl<'a, 'd> TimelineView<'a, 'd> {
note_context: &'a mut NoteContext<'d>,
note_options: NoteOptions,
cur_acc: &'a Option<KeypairUnowned<'a>>,
jobs: &'a mut JobsCache,
) -> Self {
let reverse = false;
TimelineView {
@@ -42,6 +45,7 @@ impl<'a, 'd> TimelineView<'a, 'd> {
is_muted,
note_context,
cur_acc,
jobs,
}
}
@@ -55,6 +59,7 @@ impl<'a, 'd> TimelineView<'a, 'd> {
self.is_muted,
self.note_context,
self.cur_acc,
self.jobs,
)
}
@@ -74,6 +79,7 @@ fn timeline_ui(
is_muted: &MuteFun,
note_context: &mut NoteContext,
cur_acc: &Option<KeypairUnowned>,
jobs: &mut JobsCache,
) -> Option<NoteAction> {
//padding(4.0, ui, |ui| ui.heading("Notifications"));
/*
@@ -152,6 +158,7 @@ fn timeline_ui(
is_muted,
note_context,
cur_acc,
jobs,
)
.show(ui)
});
@@ -323,6 +330,7 @@ pub struct TimelineTabView<'a, 'd> {
is_muted: &'a MuteFun,
note_context: &'a mut NoteContext<'d>,
cur_acc: &'a Option<KeypairUnowned<'a>>,
jobs: &'a mut JobsCache,
}
impl<'a, 'd> TimelineTabView<'a, 'd> {
@@ -335,6 +343,7 @@ impl<'a, 'd> TimelineTabView<'a, 'd> {
is_muted: &'a MuteFun,
note_context: &'a mut NoteContext<'d>,
cur_acc: &'a Option<KeypairUnowned<'a>>,
jobs: &'a mut JobsCache,
) -> Self {
Self {
tab,
@@ -344,6 +353,7 @@ impl<'a, 'd> TimelineTabView<'a, 'd> {
is_muted,
note_context,
cur_acc,
jobs,
}
}
@@ -395,6 +405,7 @@ impl<'a, 'd> TimelineTabView<'a, 'd> {
self.cur_acc,
&note,
self.note_options,
self.jobs,
)
.show(ui);