commit a07796cb43fab538381f2861da5d26e858b773f6
parent 49bad7b04178782c4735a7d6cfaf8b8dc252be26
Author: kernelkind <kernelkind@gmail.com>
Date: Sat, 22 Nov 2025 21:33:08 -0700
feat(media-jobs): add media JobCache to app
Signed-off-by: kernelkind <kernelkind@gmail.com>
Diffstat:
4 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/crates/notedeck/src/app.rs b/crates/notedeck/src/app.rs
@@ -3,13 +3,13 @@ use crate::i18n::Localization;
use crate::persist::{AppSizeHandler, SettingsHandler};
use crate::wallet::GlobalWallet;
use crate::zaps::Zaps;
-use crate::Error;
-use crate::JobPool;
use crate::NotedeckOptions;
use crate::{
frame_history::FrameHistory, AccountStorage, Accounts, AppContext, Args, DataPath,
DataPathType, Directory, Images, NoteAction, NoteCache, RelayDebugView, UnknownIds,
};
+use crate::{Error, JobCache};
+use crate::{JobPool, MediaJobs};
use egui::Margin;
use egui::ThemePreference;
use egui_winit::clipboard::Clipboard;
@@ -77,6 +77,7 @@ pub struct Notedeck {
zaps: Zaps,
frame_history: FrameHistory,
job_pool: JobPool,
+ media_jobs: MediaJobs,
i18n: Localization,
#[cfg(target_os = "android")]
@@ -122,6 +123,13 @@ impl eframe::App for Notedeck {
self.frame_history
.on_new_frame(ctx.input(|i| i.time), frame.info().cpu_usage);
+ self.media_jobs.run_received(&mut self.job_pool, |id| {
+ crate::run_media_job_pre_action(id, &mut self.img_cache.textures);
+ });
+ self.media_jobs.deliver_all_completed(|completed| {
+ crate::deliver_completed_media_job(completed, &mut self.img_cache.textures)
+ });
+
// handle account updates
self.accounts.update(&mut self.ndb, &mut self.pool, ctx);
@@ -290,6 +298,9 @@ impl Notedeck {
}
}
+ let (send_new_jobs, receive_new_jobs) = std::sync::mpsc::channel();
+ let media_job_cache = JobCache::new(receive_new_jobs, send_new_jobs);
+
Self {
ndb,
img_cache,
@@ -308,6 +319,7 @@ impl Notedeck {
clipboard: Clipboard::new(None),
zaps,
job_pool,
+ media_jobs: media_job_cache,
i18n,
#[cfg(target_os = "android")]
android_app: None,
@@ -373,6 +385,7 @@ impl Notedeck {
zaps: &mut self.zaps,
frame_history: &mut self.frame_history,
job_pool: &mut self.job_pool,
+ media_jobs: &mut self.media_jobs,
i18n: &mut self.i18n,
#[cfg(target_os = "android")]
android: self.android_app.as_ref().unwrap().clone(),
diff --git a/crates/notedeck/src/context.rs b/crates/notedeck/src/context.rs
@@ -1,7 +1,7 @@
use crate::{
account::accounts::Accounts, frame_history::FrameHistory, i18n::Localization,
- wallet::GlobalWallet, zaps::Zaps, Args, DataPath, Images, JobPool, NoteCache, SettingsHandler,
- UnknownIds,
+ wallet::GlobalWallet, zaps::Zaps, Args, DataPath, Images, JobPool, MediaJobs, NoteCache,
+ SettingsHandler, UnknownIds,
};
use egui_winit::clipboard::Clipboard;
@@ -28,6 +28,7 @@ pub struct AppContext<'a> {
pub zaps: &'a mut Zaps,
pub frame_history: &'a mut FrameHistory,
pub job_pool: &'a mut JobPool,
+ pub media_jobs: &'a mut MediaJobs,
pub i18n: &'a mut Localization,
#[cfg(target_os = "android")]
diff --git a/crates/notedeck/src/jobs/mod.rs b/crates/notedeck/src/jobs/mod.rs
@@ -14,5 +14,5 @@ pub use cache_old::{
pub use job_pool::JobPool;
pub use media::{
deliver_completed_media_job, run_media_job_pre_action, MediaJobKind, MediaJobResult,
- MediaJobSender,
+ MediaJobSender, MediaJobs,
};
diff --git a/crates/notedeck/src/lib.rs b/crates/notedeck/src/lib.rs
@@ -59,8 +59,8 @@ pub use imgcache::{
TextureState, TextureStateOld, TexturedImage, TexturesCache, TexturesCacheOld,
};
pub use jobs::{
- BlurhashParams, Job, JobError, JobIdOld, JobParams, JobParamsOwned, JobPool, JobState,
- JobsCacheOld,
+ deliver_completed_media_job, run_media_job_pre_action, BlurhashParams, Job, JobCache, JobError,
+ JobIdOld, JobParams, JobParamsOwned, JobPool, JobState, JobsCacheOld, MediaJobs,
};
pub use media::{
compute_blurhash, update_imeta_blurhashes, ImageMetadata, ImageType, MediaAction,