diff --git a/crates/notedeck/src/app.rs b/crates/notedeck/src/app.rs index dfb4468..170cef8 100644 --- a/crates/notedeck/src/app.rs +++ b/crates/notedeck/src/app.rs @@ -1,7 +1,7 @@ use crate::persist::{AppSizeHandler, ZoomHandler}; use crate::{ - Accounts, AppContext, Args, DataPath, DataPathType, Directory, FileKeyStorage, ImageCache, - KeyStorageType, NoteCache, RelayDebugView, ThemeHandler, UnknownIds, + Accounts, AppContext, Args, DataPath, DataPathType, Directory, FileKeyStorage, KeyStorageType, + MediaCache, NoteCache, RelayDebugView, ThemeHandler, UnknownIds, }; use egui::ThemePreference; use enostr::RelayPool; @@ -19,7 +19,7 @@ pub trait App { /// Main notedeck app framework pub struct Notedeck { ndb: Ndb, - img_cache: ImageCache, + img_cache: MediaCache, unknown_ids: UnknownIds, pool: RelayPool, note_cache: NoteCache, @@ -129,7 +129,7 @@ impl Notedeck { let _ = std::fs::create_dir_all(&dbpath_str); - let img_cache_dir = path.path(DataPathType::Cache).join(ImageCache::rel_dir()); + let img_cache_dir = path.path(DataPathType::Cache).join(MediaCache::rel_dir()); let _ = std::fs::create_dir_all(img_cache_dir.clone()); let map_size = if cfg!(target_os = "windows") { @@ -184,7 +184,7 @@ impl Notedeck { } } - let img_cache = ImageCache::new(img_cache_dir); + let img_cache = MediaCache::new(img_cache_dir); let note_cache = NoteCache::default(); let unknown_ids = UnknownIds::default(); let zoom = ZoomHandler::new(&path); diff --git a/crates/notedeck/src/context.rs b/crates/notedeck/src/context.rs index 5801fba..5cf2b7a 100644 --- a/crates/notedeck/src/context.rs +++ b/crates/notedeck/src/context.rs @@ -1,4 +1,4 @@ -use crate::{Accounts, Args, DataPath, ImageCache, NoteCache, ThemeHandler, UnknownIds}; +use crate::{Accounts, Args, DataPath, MediaCache, NoteCache, ThemeHandler, UnknownIds}; use enostr::RelayPool; use nostrdb::Ndb; @@ -7,7 +7,7 @@ use nostrdb::Ndb; pub struct AppContext<'a> { pub ndb: &'a mut Ndb, - pub img_cache: &'a mut ImageCache, + pub img_cache: &'a mut MediaCache, pub unknown_ids: &'a mut UnknownIds, pub pool: &'a mut RelayPool, pub note_cache: &'a mut NoteCache, diff --git a/crates/notedeck/src/imgcache.rs b/crates/notedeck/src/imgcache.rs index 9cbe31a..6fdb7aa 100644 --- a/crates/notedeck/src/imgcache.rs +++ b/crates/notedeck/src/imgcache.rs @@ -13,15 +13,15 @@ use std::path; use std::path::PathBuf; use tracing::warn; -pub type ImageCacheValue = Promise>; -pub type ImageCacheMap = HashMap; +pub type MediaCacheValue = Promise>; +pub type MediaCacheMap = HashMap; -pub struct ImageCache { +pub struct MediaCache { pub cache_dir: path::PathBuf, - url_imgs: ImageCacheMap, + url_imgs: MediaCacheMap, } -impl ImageCache { +impl MediaCache { pub fn new(cache_dir: path::PathBuf) -> Self { Self { cache_dir, @@ -118,11 +118,11 @@ impl ImageCache { Ok(()) } - pub fn map(&self) -> &ImageCacheMap { + pub fn map(&self) -> &MediaCacheMap { &self.url_imgs } - pub fn map_mut(&mut self) -> &mut ImageCacheMap { + pub fn map_mut(&mut self) -> &mut MediaCacheMap { &mut self.url_imgs } } diff --git a/crates/notedeck/src/lib.rs b/crates/notedeck/src/lib.rs index c705323..034f11c 100644 --- a/crates/notedeck/src/lib.rs +++ b/crates/notedeck/src/lib.rs @@ -31,7 +31,7 @@ pub use context::AppContext; pub use error::{Error, FilterError}; pub use filter::{FilterState, FilterStates, UnifiedSubscription}; pub use fonts::NamedFontFamily; -pub use imgcache::ImageCache; +pub use imgcache::MediaCache; pub use muted::{MuteFun, Muted}; pub use note::{NoteRef, RootIdError, RootNoteId, RootNoteIdBuf}; pub use notecache::{CachedNote, NoteCache}; diff --git a/crates/notedeck_columns/src/accounts/mod.rs b/crates/notedeck_columns/src/accounts/mod.rs index 919fb60..6f6205c 100644 --- a/crates/notedeck_columns/src/accounts/mod.rs +++ b/crates/notedeck_columns/src/accounts/mod.rs @@ -2,7 +2,7 @@ use enostr::FullKeypair; use nostrdb::Ndb; use notedeck::{ - Accounts, AccountsAction, AddAccountAction, ImageCache, SingleUnkIdAction, SwitchAccountAction, + Accounts, AccountsAction, AddAccountAction, MediaCache, SingleUnkIdAction, SwitchAccountAction, }; use crate::app::get_active_columns_mut; @@ -27,7 +27,7 @@ pub fn render_accounts_route( ui: &mut egui::Ui, ndb: &Ndb, col: usize, - img_cache: &mut ImageCache, + img_cache: &mut MediaCache, accounts: &mut Accounts, decks: &mut DecksCache, login_state: &mut AcquireKeyState, diff --git a/crates/notedeck_columns/src/app.rs b/crates/notedeck_columns/src/app.rs index df2848f..568001d 100644 --- a/crates/notedeck_columns/src/app.rs +++ b/crates/notedeck_columns/src/app.rs @@ -13,7 +13,7 @@ use crate::{ Result, }; -use notedeck::{Accounts, AppContext, DataPath, DataPathType, FilterState, ImageCache, UnknownIds}; +use notedeck::{Accounts, AppContext, DataPath, DataPathType, FilterState, MediaCache, UnknownIds}; use enostr::{ClientMessage, Keypair, PoolRelay, Pubkey, RelayEvent, RelayMessage, RelayPool}; use uuid::Uuid; @@ -464,7 +464,7 @@ impl Damus { let decks_cache = DecksCache::default(); let path = DataPath::new(&data_path); - let imgcache_dir = path.path(DataPathType::Cache).join(ImageCache::rel_dir()); + let imgcache_dir = path.path(DataPathType::Cache).join(MediaCache::rel_dir()); let _ = std::fs::create_dir_all(imgcache_dir.clone()); let debug = true; diff --git a/crates/notedeck_columns/src/images.rs b/crates/notedeck_columns/src/images.rs index 0a0d8c5..87ae5b3 100644 --- a/crates/notedeck_columns/src/images.rs +++ b/crates/notedeck_columns/src/images.rs @@ -1,6 +1,6 @@ use egui::{pos2, Color32, ColorImage, Rect, Sense, SizeHint, TextureHandle}; use image::imageops::FilterType; -use notedeck::ImageCache; +use notedeck::MediaCache; use notedeck::Result; use poll_promise::Promise; use std::path; @@ -9,7 +9,7 @@ use tokio::fs; //pub type ImageCacheKey = String; //pub type ImageCacheValue = Promise>; -//pub type ImageCache = HashMap; +//pub type MediaCache = HashMap; // NOTE(jb55): chatgpt wrote this because I was too dumb to pub fn aspect_fill( @@ -213,12 +213,12 @@ pub enum ImageType { } pub fn fetch_img( - img_cache: &ImageCache, + img_cache: &MediaCache, ctx: &egui::Context, url: &str, imgtyp: ImageType, ) -> Promise> { - let key = ImageCache::key(url); + let key = MediaCache::key(url); let path = img_cache.cache_dir.join(key); if path.exists() { @@ -249,7 +249,7 @@ fn fetch_img_from_net( let texture_handle = ctx.load_texture(&cloned_url, img.clone(), Default::default()); // write to disk - std::thread::spawn(move || ImageCache::write(&cache_path, &cloned_url, img)); + std::thread::spawn(move || MediaCache::write(&cache_path, &cloned_url, img)); texture_handle }); diff --git a/crates/notedeck_columns/src/timeline/route.rs b/crates/notedeck_columns/src/timeline/route.rs index 51f95be..81f990a 100644 --- a/crates/notedeck_columns/src/timeline/route.rs +++ b/crates/notedeck_columns/src/timeline/route.rs @@ -7,12 +7,12 @@ use crate::{ use enostr::Pubkey; use nostrdb::Ndb; -use notedeck::{Accounts, ImageCache, MuteFun, NoteCache, UnknownIds}; +use notedeck::{Accounts, MediaCache, MuteFun, NoteCache, UnknownIds}; #[allow(clippy::too_many_arguments)] pub fn render_timeline_route( ndb: &Ndb, - img_cache: &mut ImageCache, + img_cache: &mut MediaCache, unknown_ids: &mut UnknownIds, note_cache: &mut NoteCache, timeline_cache: &mut TimelineCache, @@ -102,7 +102,7 @@ pub fn render_profile_route( accounts: &Accounts, ndb: &Ndb, timeline_cache: &mut TimelineCache, - img_cache: &mut ImageCache, + img_cache: &mut MediaCache, note_cache: &mut NoteCache, unknown_ids: &mut UnknownIds, col: usize, diff --git a/crates/notedeck_columns/src/ui/accounts.rs b/crates/notedeck_columns/src/ui/accounts.rs index 01ad659..051cfc8 100644 --- a/crates/notedeck_columns/src/ui/accounts.rs +++ b/crates/notedeck_columns/src/ui/accounts.rs @@ -3,14 +3,14 @@ use egui::{ Align, Button, Frame, Image, InnerResponse, Layout, RichText, ScrollArea, Ui, UiBuilder, Vec2, }; use nostrdb::{Ndb, Transaction}; -use notedeck::{Accounts, ImageCache}; +use notedeck::{Accounts, MediaCache}; use super::profile::preview::SimpleProfilePreview; pub struct AccountsView<'a> { ndb: &'a Ndb, accounts: &'a Accounts, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, } #[derive(Clone, Debug)] @@ -27,7 +27,7 @@ enum ProfilePreviewAction { } impl<'a> AccountsView<'a> { - pub fn new(ndb: &'a Ndb, accounts: &'a Accounts, img_cache: &'a mut ImageCache) -> Self { + pub fn new(ndb: &'a Ndb, accounts: &'a Accounts, img_cache: &'a mut MediaCache) -> Self { AccountsView { ndb, accounts, @@ -54,7 +54,7 @@ impl<'a> AccountsView<'a> { ui: &mut Ui, accounts: &Accounts, ndb: &Ndb, - img_cache: &mut ImageCache, + img_cache: &mut MediaCache, ) -> Option { let mut return_op: Option = None; ui.allocate_ui_with_layout( diff --git a/crates/notedeck_columns/src/ui/add_column.rs b/crates/notedeck_columns/src/ui/add_column.rs index 9783599..32a98dd 100644 --- a/crates/notedeck_columns/src/ui/add_column.rs +++ b/crates/notedeck_columns/src/ui/add_column.rs @@ -17,7 +17,7 @@ use crate::{ Damus, }; -use notedeck::{AppContext, ImageCache, NotedeckTextStyle, UserAccount}; +use notedeck::{AppContext, MediaCache, NotedeckTextStyle, UserAccount}; use tokenator::{ParseError, TokenParser, TokenSerializable, TokenWriter}; use super::{anim::AnimationHelper, padding, ProfilePreview}; @@ -163,7 +163,7 @@ impl AddColumnOption { pub struct AddColumnView<'a> { key_state_map: &'a mut HashMap, ndb: &'a Ndb, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, cur_account: Option<&'a UserAccount>, } @@ -171,7 +171,7 @@ impl<'a> AddColumnView<'a> { pub fn new( key_state_map: &'a mut HashMap, ndb: &'a Ndb, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, cur_account: Option<&'a UserAccount>, ) -> Self { Self { diff --git a/crates/notedeck_columns/src/ui/column/header.rs b/crates/notedeck_columns/src/ui/column/header.rs index 8804390..3713d0c 100644 --- a/crates/notedeck_columns/src/ui/column/header.rs +++ b/crates/notedeck_columns/src/ui/column/header.rs @@ -16,11 +16,11 @@ use egui::Margin; use egui::{RichText, Stroke, UiBuilder}; use enostr::Pubkey; use nostrdb::{Ndb, Transaction}; -use notedeck::{ImageCache, NotedeckTextStyle}; +use notedeck::{MediaCache, NotedeckTextStyle}; pub struct NavTitle<'a> { ndb: &'a Ndb, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, columns: &'a Columns, routes: &'a [Route], col_id: usize, @@ -29,7 +29,7 @@ pub struct NavTitle<'a> { impl<'a> NavTitle<'a> { pub fn new( ndb: &'a Ndb, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, columns: &'a Columns, routes: &'a [Route], col_id: usize, diff --git a/crates/notedeck_columns/src/ui/mention.rs b/crates/notedeck_columns/src/ui/mention.rs index 83e53ac..6ad00e4 100644 --- a/crates/notedeck_columns/src/ui/mention.rs +++ b/crates/notedeck_columns/src/ui/mention.rs @@ -3,11 +3,11 @@ use crate::{actionbar::NoteAction, profile::get_display_name, timeline::Timeline use egui::Sense; use enostr::Pubkey; use nostrdb::{Ndb, Transaction}; -use notedeck::ImageCache; +use notedeck::MediaCache; pub struct Mention<'a> { ndb: &'a Ndb, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, txn: &'a Transaction, pk: &'a [u8; 32], selectable: bool, @@ -17,7 +17,7 @@ pub struct Mention<'a> { impl<'a> Mention<'a> { pub fn new( ndb: &'a Ndb, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, txn: &'a Transaction, pk: &'a [u8; 32], ) -> Self { @@ -64,7 +64,7 @@ impl egui::Widget for Mention<'_> { fn mention_ui( ndb: &Ndb, - img_cache: &mut ImageCache, + img_cache: &mut MediaCache, txn: &Transaction, pk: &[u8; 32], ui: &mut egui::Ui, diff --git a/crates/notedeck_columns/src/ui/note/contents.rs b/crates/notedeck_columns/src/ui/note/contents.rs index 22f8fff..0ccf4ef 100644 --- a/crates/notedeck_columns/src/ui/note/contents.rs +++ b/crates/notedeck_columns/src/ui/note/contents.rs @@ -8,11 +8,11 @@ use egui::{Color32, Hyperlink, Image, RichText}; use nostrdb::{BlockType, Mention, Ndb, Note, NoteKey, Transaction}; use tracing::warn; -use notedeck::{ImageCache, NoteCache}; +use notedeck::{MediaCache, NoteCache}; pub struct NoteContents<'a> { ndb: &'a Ndb, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, note_cache: &'a mut NoteCache, txn: &'a Transaction, note: &'a Note<'a>, @@ -24,7 +24,7 @@ pub struct NoteContents<'a> { impl<'a> NoteContents<'a> { pub fn new( ndb: &'a Ndb, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, note_cache: &'a mut NoteCache, txn: &'a Transaction, note: &'a Note, @@ -72,7 +72,7 @@ pub fn render_note_preview( ui: &mut egui::Ui, ndb: &Ndb, note_cache: &mut NoteCache, - img_cache: &mut ImageCache, + img_cache: &mut MediaCache, txn: &Transaction, id: &[u8; 32], parent: NoteKey, @@ -134,7 +134,7 @@ fn is_image_link(url: &str) -> bool { fn render_note_contents( ui: &mut egui::Ui, ndb: &Ndb, - img_cache: &mut ImageCache, + img_cache: &mut MediaCache, note_cache: &mut NoteCache, txn: &Transaction, note: &Note, @@ -279,7 +279,7 @@ fn rot13(input: &str) -> String { fn image_carousel( ui: &mut egui::Ui, - img_cache: &mut ImageCache, + img_cache: &mut MediaCache, images: Vec, carousel_id: egui::Id, ) { diff --git a/crates/notedeck_columns/src/ui/note/mod.rs b/crates/notedeck_columns/src/ui/note/mod.rs index 7fe8978..4610386 100644 --- a/crates/notedeck_columns/src/ui/note/mod.rs +++ b/crates/notedeck_columns/src/ui/note/mod.rs @@ -25,14 +25,14 @@ use egui::emath::{pos2, Vec2}; use egui::{Id, Label, Pos2, Rect, Response, RichText, Sense}; use enostr::{NoteId, Pubkey}; use nostrdb::{Ndb, Note, NoteKey, Transaction}; -use notedeck::{CachedNote, ImageCache, NoteCache, NotedeckTextStyle}; +use notedeck::{CachedNote, MediaCache, NoteCache, NotedeckTextStyle}; use super::profile::preview::one_line_display_name_widget; pub struct NoteView<'a> { ndb: &'a Ndb, note_cache: &'a mut NoteCache, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, parent: Option, note: &'a nostrdb::Note<'a>, flags: NoteOptions, @@ -74,7 +74,7 @@ impl<'a> NoteView<'a> { pub fn new( ndb: &'a Ndb, note_cache: &'a mut NoteCache, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, note: &'a nostrdb::Note<'a>, mut flags: NoteOptions, ) -> Self { diff --git a/crates/notedeck_columns/src/ui/note/post.rs b/crates/notedeck_columns/src/ui/note/post.rs index 00bc677..b766b79 100644 --- a/crates/notedeck_columns/src/ui/note/post.rs +++ b/crates/notedeck_columns/src/ui/note/post.rs @@ -13,7 +13,7 @@ use egui::{vec2, Frame, Layout, Margin, Pos2, ScrollArea, Sense, TextBuffer}; use enostr::{FilledKeypair, FullKeypair, NoteId, Pubkey, RelayPool}; use nostrdb::{Ndb, Transaction}; -use notedeck::{ImageCache, NoteCache}; +use notedeck::{MediaCache, NoteCache}; use tracing::error; use super::contents::render_note_preview; @@ -22,7 +22,7 @@ pub struct PostView<'a> { ndb: &'a Ndb, draft: &'a mut Draft, post_type: PostType, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, note_cache: &'a mut NoteCache, poster: FilledKeypair<'a>, id_source: Option, @@ -88,7 +88,7 @@ impl<'a> PostView<'a> { ndb: &'a Ndb, draft: &'a mut Draft, post_type: PostType, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, note_cache: &'a mut NoteCache, poster: FilledKeypair<'a>, inner_rect: egui::Rect, diff --git a/crates/notedeck_columns/src/ui/note/quote_repost.rs b/crates/notedeck_columns/src/ui/note/quote_repost.rs index 4abad31..22f98c5 100644 --- a/crates/notedeck_columns/src/ui/note/quote_repost.rs +++ b/crates/notedeck_columns/src/ui/note/quote_repost.rs @@ -1,6 +1,6 @@ use enostr::{FilledKeypair, NoteId}; use nostrdb::Ndb; -use notedeck::{ImageCache, NoteCache}; +use notedeck::{MediaCache, NoteCache}; use crate::{ draft::Draft, @@ -13,7 +13,7 @@ pub struct QuoteRepostView<'a> { ndb: &'a Ndb, poster: FilledKeypair<'a>, note_cache: &'a mut NoteCache, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, draft: &'a mut Draft, quoting_note: &'a nostrdb::Note<'a>, id_source: Option, @@ -27,7 +27,7 @@ impl<'a> QuoteRepostView<'a> { ndb: &'a Ndb, poster: FilledKeypair<'a>, note_cache: &'a mut NoteCache, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, draft: &'a mut Draft, quoting_note: &'a nostrdb::Note<'a>, inner_rect: egui::Rect, diff --git a/crates/notedeck_columns/src/ui/note/reply.rs b/crates/notedeck_columns/src/ui/note/reply.rs index c64df0f..6aa5a62 100644 --- a/crates/notedeck_columns/src/ui/note/reply.rs +++ b/crates/notedeck_columns/src/ui/note/reply.rs @@ -4,13 +4,13 @@ use crate::ui::note::{NoteOptions, PostResponse, PostType}; use enostr::{FilledKeypair, NoteId}; use nostrdb::Ndb; -use notedeck::{ImageCache, NoteCache}; +use notedeck::{MediaCache, NoteCache}; pub struct PostReplyView<'a> { ndb: &'a Ndb, poster: FilledKeypair<'a>, note_cache: &'a mut NoteCache, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, draft: &'a mut Draft, note: &'a nostrdb::Note<'a>, id_source: Option, @@ -25,7 +25,7 @@ impl<'a> PostReplyView<'a> { poster: FilledKeypair<'a>, draft: &'a mut Draft, note_cache: &'a mut NoteCache, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, note: &'a nostrdb::Note<'a>, inner_rect: egui::Rect, note_options: NoteOptions, diff --git a/crates/notedeck_columns/src/ui/note/reply_description.rs b/crates/notedeck_columns/src/ui/note/reply_description.rs index 8c7bacd..2d28035 100644 --- a/crates/notedeck_columns/src/ui/note/reply_description.rs +++ b/crates/notedeck_columns/src/ui/note/reply_description.rs @@ -4,7 +4,7 @@ use crate::{ }; use egui::{Label, RichText, Sense}; use nostrdb::{Ndb, Note, NoteReply, Transaction}; -use notedeck::{ImageCache, NoteCache}; +use notedeck::{MediaCache, NoteCache}; #[must_use = "Please handle the resulting note action"] pub fn reply_desc( @@ -12,7 +12,7 @@ pub fn reply_desc( txn: &Transaction, note_reply: &NoteReply, ndb: &Ndb, - img_cache: &mut ImageCache, + img_cache: &mut MediaCache, note_cache: &mut NoteCache, note_options: NoteOptions, ) -> Option { @@ -29,7 +29,7 @@ pub fn reply_desc( // note link renderer helper let note_link = |ui: &mut egui::Ui, note_cache: &mut NoteCache, - img_cache: &mut ImageCache, + img_cache: &mut MediaCache, text: &str, note: &Note<'_>| { let r = ui.add( diff --git a/crates/notedeck_columns/src/ui/profile/edit.rs b/crates/notedeck_columns/src/ui/profile/edit.rs index 411f614..b6300f7 100644 --- a/crates/notedeck_columns/src/ui/profile/edit.rs +++ b/crates/notedeck_columns/src/ui/profile/edit.rs @@ -1,7 +1,7 @@ use core::f32; use egui::{vec2, Button, Layout, Margin, RichText, Rounding, ScrollArea, TextEdit}; -use notedeck::{ImageCache, NotedeckTextStyle}; +use notedeck::{MediaCache, NotedeckTextStyle}; use crate::{colors, profile_state::ProfileState}; @@ -9,11 +9,11 @@ use super::{banner, unwrap_profile_url, ProfilePic}; pub struct EditProfileView<'a> { state: &'a mut ProfileState, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, } impl<'a> EditProfileView<'a> { - pub fn new(state: &'a mut ProfileState, img_cache: &'a mut ImageCache) -> Self { + pub fn new(state: &'a mut ProfileState, img_cache: &'a mut MediaCache) -> Self { Self { state, img_cache } } diff --git a/crates/notedeck_columns/src/ui/profile/mod.rs b/crates/notedeck_columns/src/ui/profile/mod.rs index c466895..1d42921 100644 --- a/crates/notedeck_columns/src/ui/profile/mod.rs +++ b/crates/notedeck_columns/src/ui/profile/mod.rs @@ -23,7 +23,7 @@ use crate::{ NostrName, }; -use notedeck::{Accounts, ImageCache, MuteFun, NoteCache, NotedeckTextStyle, UnknownIds}; +use notedeck::{Accounts, MediaCache, MuteFun, NoteCache, NotedeckTextStyle, UnknownIds}; pub struct ProfileView<'a> { pubkey: &'a Pubkey, @@ -33,7 +33,7 @@ pub struct ProfileView<'a> { note_options: NoteOptions, ndb: &'a Ndb, note_cache: &'a mut NoteCache, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, unknown_ids: &'a mut UnknownIds, is_muted: &'a MuteFun, } @@ -52,7 +52,7 @@ impl<'a> ProfileView<'a> { timeline_cache: &'a mut TimelineCache, ndb: &'a Ndb, note_cache: &'a mut NoteCache, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, unknown_ids: &'a mut UnknownIds, is_muted: &'a MuteFun, note_options: NoteOptions, diff --git a/crates/notedeck_columns/src/ui/profile/picture.rs b/crates/notedeck_columns/src/ui/profile/picture.rs index 541683d..d8455a6 100644 --- a/crates/notedeck_columns/src/ui/profile/picture.rs +++ b/crates/notedeck_columns/src/ui/profile/picture.rs @@ -4,10 +4,10 @@ use egui::{vec2, Sense, Stroke, TextureHandle}; use nostrdb::{Ndb, Transaction}; use tracing::info; -use notedeck::{AppContext, ImageCache}; +use notedeck::{AppContext, MediaCache}; pub struct ProfilePic<'cache, 'url> { - cache: &'cache mut ImageCache, + cache: &'cache mut MediaCache, url: &'url str, size: f32, border: Option, @@ -20,7 +20,7 @@ impl egui::Widget for ProfilePic<'_, '_> { } impl<'cache, 'url> ProfilePic<'cache, 'url> { - pub fn new(cache: &'cache mut ImageCache, url: &'url str) -> Self { + pub fn new(cache: &'cache mut MediaCache, url: &'url str) -> Self { let size = Self::default_size(); ProfilePic { cache, @@ -35,7 +35,7 @@ impl<'cache, 'url> ProfilePic<'cache, 'url> { } pub fn from_profile( - cache: &'cache mut ImageCache, + cache: &'cache mut MediaCache, profile: &nostrdb::ProfileRecord<'url>, ) -> Option { profile @@ -80,7 +80,7 @@ impl<'cache, 'url> ProfilePic<'cache, 'url> { fn render_pfp( ui: &mut egui::Ui, - img_cache: &mut ImageCache, + img_cache: &mut MediaCache, url: &str, ui_size: f32, border: Option, diff --git a/crates/notedeck_columns/src/ui/profile/preview.rs b/crates/notedeck_columns/src/ui/profile/preview.rs index de1bbc2..8cdbc2b 100644 --- a/crates/notedeck_columns/src/ui/profile/preview.rs +++ b/crates/notedeck_columns/src/ui/profile/preview.rs @@ -4,18 +4,18 @@ use egui::{Frame, Label, RichText, Widget}; use egui_extras::Size; use nostrdb::ProfileRecord; -use notedeck::{ImageCache, NotedeckTextStyle, UserAccount}; +use notedeck::{MediaCache, NotedeckTextStyle, UserAccount}; use super::{about_section_widget, banner, display_name_widget, get_display_name, get_profile_url}; pub struct ProfilePreview<'a, 'cache> { profile: &'a ProfileRecord<'a>, - cache: &'cache mut ImageCache, + cache: &'cache mut MediaCache, banner_height: Size, } impl<'a, 'cache> ProfilePreview<'a, 'cache> { - pub fn new(profile: &'a ProfileRecord<'a>, cache: &'cache mut ImageCache) -> Self { + pub fn new(profile: &'a ProfileRecord<'a>, cache: &'cache mut MediaCache) -> Self { let banner_height = Size::exact(80.0); ProfilePreview { profile, @@ -69,14 +69,14 @@ impl egui::Widget for ProfilePreview<'_, '_> { pub struct SimpleProfilePreview<'a, 'cache> { profile: Option<&'a ProfileRecord<'a>>, - cache: &'cache mut ImageCache, + cache: &'cache mut MediaCache, is_nsec: bool, } impl<'a, 'cache> SimpleProfilePreview<'a, 'cache> { pub fn new( profile: Option<&'a ProfileRecord<'a>>, - cache: &'cache mut ImageCache, + cache: &'cache mut MediaCache, is_nsec: bool, ) -> Self { SimpleProfilePreview { diff --git a/crates/notedeck_columns/src/ui/search_results.rs b/crates/notedeck_columns/src/ui/search_results.rs index 5497faf..ef64b21 100644 --- a/crates/notedeck_columns/src/ui/search_results.rs +++ b/crates/notedeck_columns/src/ui/search_results.rs @@ -1,6 +1,6 @@ use egui::{vec2, FontId, Pos2, Rect, ScrollArea, Vec2b}; use nostrdb::{Ndb, ProfileRecord, Transaction}; -use notedeck::{fonts::get_font_size, ImageCache, NotedeckTextStyle}; +use notedeck::{fonts::get_font_size, MediaCache, NotedeckTextStyle}; use tracing::error; use crate::{ @@ -13,13 +13,13 @@ use super::{profile::get_profile_url, ProfilePic}; pub struct SearchResultsView<'a> { ndb: &'a Ndb, txn: &'a Transaction, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, results: &'a Vec<&'a [u8; 32]>, } impl<'a> SearchResultsView<'a> { pub fn new( - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, ndb: &'a Ndb, txn: &'a Transaction, results: &'a Vec<&'a [u8; 32]>, @@ -84,7 +84,7 @@ impl<'a> SearchResultsView<'a> { fn user_result<'a>( profile: &'a ProfileRecord<'_>, - cache: &'a mut ImageCache, + cache: &'a mut MediaCache, index: usize, width: f32, ) -> impl egui::Widget + 'a { diff --git a/crates/notedeck_columns/src/ui/side_panel.rs b/crates/notedeck_columns/src/ui/side_panel.rs index b864206..7682d34 100644 --- a/crates/notedeck_columns/src/ui/side_panel.rs +++ b/crates/notedeck_columns/src/ui/side_panel.rs @@ -15,7 +15,7 @@ use crate::{ support::Support, }; -use notedeck::{Accounts, ImageCache, NotedeckTextStyle, ThemeHandler, UserAccount}; +use notedeck::{Accounts, MediaCache, NotedeckTextStyle, ThemeHandler, UserAccount}; use super::{ anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE}, @@ -29,7 +29,7 @@ static ICON_WIDTH: f32 = 40.0; pub struct DesktopSidePanel<'a> { ndb: &'a nostrdb::Ndb, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, selected_account: Option<&'a UserAccount>, decks_cache: &'a DecksCache, } @@ -70,7 +70,7 @@ impl SidePanelResponse { impl<'a> DesktopSidePanel<'a> { pub fn new( ndb: &'a nostrdb::Ndb, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, selected_account: Option<&'a UserAccount>, decks_cache: &'a DecksCache, ) -> Self { diff --git a/crates/notedeck_columns/src/ui/thread.rs b/crates/notedeck_columns/src/ui/thread.rs index 94a04c7..16f357f 100644 --- a/crates/notedeck_columns/src/ui/thread.rs +++ b/crates/notedeck_columns/src/ui/thread.rs @@ -5,7 +5,7 @@ use crate::{ }; use nostrdb::{Ndb, Transaction}; -use notedeck::{ImageCache, MuteFun, NoteCache, RootNoteId, UnknownIds}; +use notedeck::{MediaCache, MuteFun, NoteCache, RootNoteId, UnknownIds}; use tracing::error; use super::timeline::TimelineTabView; @@ -15,7 +15,7 @@ pub struct ThreadView<'a> { ndb: &'a Ndb, note_cache: &'a mut NoteCache, unknown_ids: &'a mut UnknownIds, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, selected_note_id: &'a [u8; 32], note_options: NoteOptions, id_source: egui::Id, @@ -29,7 +29,7 @@ impl<'a> ThreadView<'a> { ndb: &'a Ndb, note_cache: &'a mut NoteCache, unknown_ids: &'a mut UnknownIds, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, selected_note_id: &'a [u8; 32], note_options: NoteOptions, is_muted: &'a MuteFun, diff --git a/crates/notedeck_columns/src/ui/timeline.rs b/crates/notedeck_columns/src/ui/timeline.rs index 2236816..880883d 100644 --- a/crates/notedeck_columns/src/ui/timeline.rs +++ b/crates/notedeck_columns/src/ui/timeline.rs @@ -12,7 +12,7 @@ use egui::{vec2, Direction, Layout, Pos2, Stroke}; use egui_tabs::TabColor; use nostrdb::{Ndb, Transaction}; use notedeck::note::root_note_id_from_selected_id; -use notedeck::{ImageCache, MuteFun, NoteCache}; +use notedeck::{MediaCache, MuteFun, NoteCache}; use tracing::{error, warn}; use super::anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE}; @@ -22,7 +22,7 @@ pub struct TimelineView<'a> { timeline_cache: &'a mut TimelineCache, ndb: &'a Ndb, note_cache: &'a mut NoteCache, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, note_options: NoteOptions, reverse: bool, is_muted: &'a MuteFun, @@ -34,7 +34,7 @@ impl<'a> TimelineView<'a> { timeline_cache: &'a mut TimelineCache, ndb: &'a Ndb, note_cache: &'a mut NoteCache, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, note_options: NoteOptions, is_muted: &'a MuteFun, ) -> TimelineView<'a> { @@ -78,7 +78,7 @@ fn timeline_ui( timeline_id: &TimelineKind, timeline_cache: &mut TimelineCache, note_cache: &mut NoteCache, - img_cache: &mut ImageCache, + img_cache: &mut MediaCache, reversed: bool, note_options: NoteOptions, is_muted: &MuteFun, @@ -321,7 +321,7 @@ pub struct TimelineTabView<'a> { txn: &'a Transaction, ndb: &'a Ndb, note_cache: &'a mut NoteCache, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, is_muted: &'a MuteFun, } @@ -334,7 +334,7 @@ impl<'a> TimelineTabView<'a> { txn: &'a Transaction, ndb: &'a Ndb, note_cache: &'a mut NoteCache, - img_cache: &'a mut ImageCache, + img_cache: &'a mut MediaCache, is_muted: &'a MuteFun, ) -> Self { Self {