migrate to using Images instead of MediaCache directly
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
use crate::persist::{AppSizeHandler, ZoomHandler};
|
use crate::persist::{AppSizeHandler, ZoomHandler};
|
||||||
use crate::{
|
use crate::{
|
||||||
Accounts, AppContext, Args, DataPath, DataPathType, Directory, FileKeyStorage, KeyStorageType,
|
Accounts, AppContext, Args, DataPath, DataPathType, Directory, FileKeyStorage, Images,
|
||||||
MediaCache, NoteCache, RelayDebugView, ThemeHandler, UnknownIds,
|
KeyStorageType, NoteCache, RelayDebugView, ThemeHandler, UnknownIds,
|
||||||
};
|
};
|
||||||
use egui::ThemePreference;
|
use egui::ThemePreference;
|
||||||
use enostr::RelayPool;
|
use enostr::RelayPool;
|
||||||
@@ -19,7 +19,7 @@ pub trait App {
|
|||||||
/// Main notedeck app framework
|
/// Main notedeck app framework
|
||||||
pub struct Notedeck {
|
pub struct Notedeck {
|
||||||
ndb: Ndb,
|
ndb: Ndb,
|
||||||
img_cache: MediaCache,
|
img_cache: Images,
|
||||||
unknown_ids: UnknownIds,
|
unknown_ids: UnknownIds,
|
||||||
pool: RelayPool,
|
pool: RelayPool,
|
||||||
note_cache: NoteCache,
|
note_cache: NoteCache,
|
||||||
@@ -129,9 +129,7 @@ impl Notedeck {
|
|||||||
|
|
||||||
let _ = std::fs::create_dir_all(&dbpath_str);
|
let _ = std::fs::create_dir_all(&dbpath_str);
|
||||||
|
|
||||||
let img_cache_dir = path
|
let img_cache_dir = path.path(DataPathType::Cache);
|
||||||
.path(DataPathType::Cache)
|
|
||||||
.join(MediaCache::rel_dir(crate::imgcache::MediaCacheType::Image));
|
|
||||||
let _ = std::fs::create_dir_all(img_cache_dir.clone());
|
let _ = std::fs::create_dir_all(img_cache_dir.clone());
|
||||||
|
|
||||||
let map_size = if cfg!(target_os = "windows") {
|
let map_size = if cfg!(target_os = "windows") {
|
||||||
@@ -186,7 +184,7 @@ impl Notedeck {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let img_cache = MediaCache::new(img_cache_dir);
|
let img_cache = Images::new(img_cache_dir);
|
||||||
let note_cache = NoteCache::default();
|
let note_cache = NoteCache::default();
|
||||||
let unknown_ids = UnknownIds::default();
|
let unknown_ids = UnknownIds::default();
|
||||||
let zoom = ZoomHandler::new(&path);
|
let zoom = ZoomHandler::new(&path);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::{Accounts, Args, DataPath, MediaCache, NoteCache, ThemeHandler, UnknownIds};
|
use crate::{Accounts, Args, DataPath, Images, NoteCache, ThemeHandler, UnknownIds};
|
||||||
|
|
||||||
use enostr::RelayPool;
|
use enostr::RelayPool;
|
||||||
use nostrdb::Ndb;
|
use nostrdb::Ndb;
|
||||||
@@ -7,7 +7,7 @@ use nostrdb::Ndb;
|
|||||||
|
|
||||||
pub struct AppContext<'a> {
|
pub struct AppContext<'a> {
|
||||||
pub ndb: &'a mut Ndb,
|
pub ndb: &'a mut Ndb,
|
||||||
pub img_cache: &'a mut MediaCache,
|
pub img_cache: &'a mut Images,
|
||||||
pub unknown_ids: &'a mut UnknownIds,
|
pub unknown_ids: &'a mut UnknownIds,
|
||||||
pub pool: &'a mut RelayPool,
|
pub pool: &'a mut RelayPool,
|
||||||
pub note_cache: &'a mut NoteCache,
|
pub note_cache: &'a mut NoteCache,
|
||||||
|
|||||||
@@ -149,7 +149,6 @@ pub fn get_texture(textured_image: &TexturedImage) -> &TextureHandle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub struct Images {
|
pub struct Images {
|
||||||
pub static_imgs: MediaCache,
|
pub static_imgs: MediaCache,
|
||||||
pub gifs: MediaCache,
|
pub gifs: MediaCache,
|
||||||
@@ -158,7 +157,6 @@ pub struct Images {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Images {
|
impl Images {
|
||||||
#[allow(dead_code)]
|
|
||||||
/// path to directory to place [`MediaCache`]s
|
/// path to directory to place [`MediaCache`]s
|
||||||
pub fn new(path: path::PathBuf) -> Self {
|
pub fn new(path: path::PathBuf) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -169,7 +167,6 @@ impl Images {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn migrate_v0(&self) -> Result<()> {
|
pub fn migrate_v0(&self) -> Result<()> {
|
||||||
self.static_imgs.migrate_v0()?;
|
self.static_imgs.migrate_v0()?;
|
||||||
self.gifs.migrate_v0()
|
self.gifs.migrate_v0()
|
||||||
|
|||||||
@@ -31,7 +31,9 @@ pub use context::AppContext;
|
|||||||
pub use error::{Error, FilterError};
|
pub use error::{Error, FilterError};
|
||||||
pub use filter::{FilterState, FilterStates, UnifiedSubscription};
|
pub use filter::{FilterState, FilterStates, UnifiedSubscription};
|
||||||
pub use fonts::NamedFontFamily;
|
pub use fonts::NamedFontFamily;
|
||||||
pub use imgcache::{get_texture, GifState, GifStateMap, MediaCache, MediaCacheType, TexturedImage};
|
pub use imgcache::{
|
||||||
|
get_texture, GifState, GifStateMap, Images, MediaCache, MediaCacheType, TexturedImage,
|
||||||
|
};
|
||||||
pub use muted::{MuteFun, Muted};
|
pub use muted::{MuteFun, Muted};
|
||||||
pub use note::{NoteRef, RootIdError, RootNoteId, RootNoteIdBuf};
|
pub use note::{NoteRef, RootIdError, RootNoteId, RootNoteIdBuf};
|
||||||
pub use notecache::{CachedNote, NoteCache};
|
pub use notecache::{CachedNote, NoteCache};
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ fn read_from_disk(path: PathBuf) -> Promise<Option<UrlsToMime>> {
|
|||||||
match result {
|
match result {
|
||||||
Ok(data) => sender.send(Some(data)),
|
Ok(data) => sender.send(Some(data)),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::error!("problem deserializing UrlCache: {e}");
|
tracing::error!("problem deserializing UrlMimes: {e}");
|
||||||
sender.send(None)
|
sender.send(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,13 +116,13 @@ fn save_to_disk(path: PathBuf, cache: Arc<RwLock<UrlsToMime>>) {
|
|||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(Error::Generic(
|
Err(Error::Generic(
|
||||||
"Could not read UrlCache behind RwLock".to_owned(),
|
"Could not read UrlMimes behind RwLock".to_owned(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
tracing::error!("Failed to save UrlCache: {}", e);
|
tracing::error!("Failed to save UrlMimes: {}", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ fn ehttp_get_mime_type(url: &str, sender: poll_promise::Sender<MimeResult>) {
|
|||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
sender.send(MimeResult::Err(HttpError::HttpFailure));
|
sender.send(MimeResult::Err(HttpError::HttpFailure));
|
||||||
tracing::error!("failed ehttp for UrlCache: {err}");
|
tracing::error!("failed ehttp for UrlMimes: {err}");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use enostr::FullKeypair;
|
|||||||
use nostrdb::Ndb;
|
use nostrdb::Ndb;
|
||||||
|
|
||||||
use notedeck::{
|
use notedeck::{
|
||||||
Accounts, AccountsAction, AddAccountAction, MediaCache, SingleUnkIdAction, SwitchAccountAction,
|
Accounts, AccountsAction, AddAccountAction, Images, SingleUnkIdAction, SwitchAccountAction,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::get_active_columns_mut;
|
use crate::app::get_active_columns_mut;
|
||||||
@@ -27,7 +27,7 @@ pub fn render_accounts_route(
|
|||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
ndb: &Ndb,
|
ndb: &Ndb,
|
||||||
col: usize,
|
col: usize,
|
||||||
img_cache: &mut MediaCache,
|
img_cache: &mut Images,
|
||||||
accounts: &mut Accounts,
|
accounts: &mut Accounts,
|
||||||
decks: &mut DecksCache,
|
decks: &mut DecksCache,
|
||||||
login_state: &mut AcquireKeyState,
|
login_state: &mut AcquireKeyState,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use crate::{
|
|||||||
Result,
|
Result,
|
||||||
};
|
};
|
||||||
|
|
||||||
use notedeck::{Accounts, AppContext, DataPath, DataPathType, FilterState, MediaCache, UnknownIds};
|
use notedeck::{Accounts, AppContext, DataPath, DataPathType, FilterState, UnknownIds};
|
||||||
|
|
||||||
use enostr::{ClientMessage, Keypair, PoolRelay, Pubkey, RelayEvent, RelayMessage, RelayPool};
|
use enostr::{ClientMessage, Keypair, PoolRelay, Pubkey, RelayEvent, RelayMessage, RelayPool};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
@@ -464,9 +464,7 @@ impl Damus {
|
|||||||
let decks_cache = DecksCache::default();
|
let decks_cache = DecksCache::default();
|
||||||
|
|
||||||
let path = DataPath::new(&data_path);
|
let path = DataPath::new(&data_path);
|
||||||
let imgcache_dir = path
|
let imgcache_dir = path.path(DataPathType::Cache);
|
||||||
.path(DataPathType::Cache)
|
|
||||||
.join(MediaCache::rel_dir(notedeck::MediaCacheType::Image));
|
|
||||||
let _ = std::fs::create_dir_all(imgcache_dir.clone());
|
let _ = std::fs::create_dir_all(imgcache_dir.clone());
|
||||||
let debug = true;
|
let debug = true;
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ use crate::{
|
|||||||
|
|
||||||
use enostr::Pubkey;
|
use enostr::Pubkey;
|
||||||
use nostrdb::Ndb;
|
use nostrdb::Ndb;
|
||||||
use notedeck::{Accounts, MediaCache, MuteFun, NoteCache, UnknownIds};
|
use notedeck::{Accounts, Images, MuteFun, NoteCache, UnknownIds};
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn render_timeline_route(
|
pub fn render_timeline_route(
|
||||||
ndb: &Ndb,
|
ndb: &Ndb,
|
||||||
img_cache: &mut MediaCache,
|
img_cache: &mut Images,
|
||||||
unknown_ids: &mut UnknownIds,
|
unknown_ids: &mut UnknownIds,
|
||||||
note_cache: &mut NoteCache,
|
note_cache: &mut NoteCache,
|
||||||
timeline_cache: &mut TimelineCache,
|
timeline_cache: &mut TimelineCache,
|
||||||
@@ -102,7 +102,7 @@ pub fn render_profile_route(
|
|||||||
accounts: &Accounts,
|
accounts: &Accounts,
|
||||||
ndb: &Ndb,
|
ndb: &Ndb,
|
||||||
timeline_cache: &mut TimelineCache,
|
timeline_cache: &mut TimelineCache,
|
||||||
img_cache: &mut MediaCache,
|
img_cache: &mut Images,
|
||||||
note_cache: &mut NoteCache,
|
note_cache: &mut NoteCache,
|
||||||
unknown_ids: &mut UnknownIds,
|
unknown_ids: &mut UnknownIds,
|
||||||
col: usize,
|
col: usize,
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ use egui::{
|
|||||||
Align, Button, Frame, Image, InnerResponse, Layout, RichText, ScrollArea, Ui, UiBuilder, Vec2,
|
Align, Button, Frame, Image, InnerResponse, Layout, RichText, ScrollArea, Ui, UiBuilder, Vec2,
|
||||||
};
|
};
|
||||||
use nostrdb::{Ndb, Transaction};
|
use nostrdb::{Ndb, Transaction};
|
||||||
use notedeck::{Accounts, MediaCache};
|
use notedeck::{Accounts, Images};
|
||||||
|
|
||||||
use super::profile::preview::SimpleProfilePreview;
|
use super::profile::preview::SimpleProfilePreview;
|
||||||
|
|
||||||
pub struct AccountsView<'a> {
|
pub struct AccountsView<'a> {
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
accounts: &'a Accounts,
|
accounts: &'a Accounts,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
@@ -27,7 +27,7 @@ enum ProfilePreviewAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AccountsView<'a> {
|
impl<'a> AccountsView<'a> {
|
||||||
pub fn new(ndb: &'a Ndb, accounts: &'a Accounts, img_cache: &'a mut MediaCache) -> Self {
|
pub fn new(ndb: &'a Ndb, accounts: &'a Accounts, img_cache: &'a mut Images) -> Self {
|
||||||
AccountsView {
|
AccountsView {
|
||||||
ndb,
|
ndb,
|
||||||
accounts,
|
accounts,
|
||||||
@@ -54,7 +54,7 @@ impl<'a> AccountsView<'a> {
|
|||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
accounts: &Accounts,
|
accounts: &Accounts,
|
||||||
ndb: &Ndb,
|
ndb: &Ndb,
|
||||||
img_cache: &mut MediaCache,
|
img_cache: &mut Images,
|
||||||
) -> Option<AccountsViewResponse> {
|
) -> Option<AccountsViewResponse> {
|
||||||
let mut return_op: Option<AccountsViewResponse> = None;
|
let mut return_op: Option<AccountsViewResponse> = None;
|
||||||
ui.allocate_ui_with_layout(
|
ui.allocate_ui_with_layout(
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use crate::{
|
|||||||
Damus,
|
Damus,
|
||||||
};
|
};
|
||||||
|
|
||||||
use notedeck::{AppContext, MediaCache, NotedeckTextStyle, UserAccount};
|
use notedeck::{AppContext, Images, NotedeckTextStyle, UserAccount};
|
||||||
use tokenator::{ParseError, TokenParser, TokenSerializable, TokenWriter};
|
use tokenator::{ParseError, TokenParser, TokenSerializable, TokenWriter};
|
||||||
|
|
||||||
use super::{anim::AnimationHelper, padding, ProfilePreview};
|
use super::{anim::AnimationHelper, padding, ProfilePreview};
|
||||||
@@ -163,7 +163,7 @@ impl AddColumnOption {
|
|||||||
pub struct AddColumnView<'a> {
|
pub struct AddColumnView<'a> {
|
||||||
key_state_map: &'a mut HashMap<Id, AcquireKeyState>,
|
key_state_map: &'a mut HashMap<Id, AcquireKeyState>,
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
cur_account: Option<&'a UserAccount>,
|
cur_account: Option<&'a UserAccount>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ impl<'a> AddColumnView<'a> {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
key_state_map: &'a mut HashMap<Id, AcquireKeyState>,
|
key_state_map: &'a mut HashMap<Id, AcquireKeyState>,
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
cur_account: Option<&'a UserAccount>,
|
cur_account: Option<&'a UserAccount>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ use egui::Margin;
|
|||||||
use egui::{RichText, Stroke, UiBuilder};
|
use egui::{RichText, Stroke, UiBuilder};
|
||||||
use enostr::Pubkey;
|
use enostr::Pubkey;
|
||||||
use nostrdb::{Ndb, Transaction};
|
use nostrdb::{Ndb, Transaction};
|
||||||
use notedeck::{MediaCache, NotedeckTextStyle};
|
use notedeck::{Images, NotedeckTextStyle};
|
||||||
|
|
||||||
pub struct NavTitle<'a> {
|
pub struct NavTitle<'a> {
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
columns: &'a Columns,
|
columns: &'a Columns,
|
||||||
routes: &'a [Route],
|
routes: &'a [Route],
|
||||||
col_id: usize,
|
col_id: usize,
|
||||||
@@ -29,7 +29,7 @@ pub struct NavTitle<'a> {
|
|||||||
impl<'a> NavTitle<'a> {
|
impl<'a> NavTitle<'a> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
columns: &'a Columns,
|
columns: &'a Columns,
|
||||||
routes: &'a [Route],
|
routes: &'a [Route],
|
||||||
col_id: usize,
|
col_id: usize,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use notedeck::{Images, MediaCache, MediaCacheType, TexturedImage};
|
use notedeck::{Images, MediaCache, TexturedImage};
|
||||||
|
|
||||||
use crate::images::ImageType;
|
use crate::images::ImageType;
|
||||||
|
|
||||||
@@ -9,15 +9,11 @@ pub fn render_images(
|
|||||||
images: &mut Images,
|
images: &mut Images,
|
||||||
url: &str,
|
url: &str,
|
||||||
img_type: ImageType,
|
img_type: ImageType,
|
||||||
cache_type: MediaCacheType,
|
|
||||||
show_waiting: impl FnOnce(&mut egui::Ui),
|
show_waiting: impl FnOnce(&mut egui::Ui),
|
||||||
show_error: impl FnOnce(&mut egui::Ui, String),
|
show_error: impl FnOnce(&mut egui::Ui, String),
|
||||||
show_success: impl FnOnce(&mut egui::Ui, &str, &mut TexturedImage),
|
show_success: impl FnOnce(&mut egui::Ui, &str, &mut TexturedImage),
|
||||||
) -> egui::Response {
|
) -> egui::Response {
|
||||||
let cache = match cache_type.clone() {
|
let cache = &mut images.static_imgs;
|
||||||
MediaCacheType::Image => &mut images.static_imgs,
|
|
||||||
MediaCacheType::Gif => &mut images.gifs,
|
|
||||||
};
|
|
||||||
|
|
||||||
render_media_cache(
|
render_media_cache(
|
||||||
ui,
|
ui,
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ use crate::{actionbar::NoteAction, profile::get_display_name, timeline::Timeline
|
|||||||
use egui::Sense;
|
use egui::Sense;
|
||||||
use enostr::Pubkey;
|
use enostr::Pubkey;
|
||||||
use nostrdb::{Ndb, Transaction};
|
use nostrdb::{Ndb, Transaction};
|
||||||
use notedeck::MediaCache;
|
use notedeck::Images;
|
||||||
|
|
||||||
pub struct Mention<'a> {
|
pub struct Mention<'a> {
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
txn: &'a Transaction,
|
txn: &'a Transaction,
|
||||||
pk: &'a [u8; 32],
|
pk: &'a [u8; 32],
|
||||||
selectable: bool,
|
selectable: bool,
|
||||||
@@ -17,7 +17,7 @@ pub struct Mention<'a> {
|
|||||||
impl<'a> Mention<'a> {
|
impl<'a> Mention<'a> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
txn: &'a Transaction,
|
txn: &'a Transaction,
|
||||||
pk: &'a [u8; 32],
|
pk: &'a [u8; 32],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@@ -62,9 +62,10 @@ impl egui::Widget for Mention<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn mention_ui(
|
fn mention_ui(
|
||||||
ndb: &Ndb,
|
ndb: &Ndb,
|
||||||
img_cache: &mut MediaCache,
|
img_cache: &mut Images,
|
||||||
txn: &Transaction,
|
txn: &Transaction,
|
||||||
pk: &[u8; 32],
|
pk: &[u8; 32],
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
use crate::ui::images::render_images;
|
||||||
use crate::ui::{
|
use crate::ui::{
|
||||||
self,
|
self,
|
||||||
images::render_media_cache,
|
|
||||||
note::{NoteOptions, NoteResponse},
|
note::{NoteOptions, NoteResponse},
|
||||||
};
|
};
|
||||||
use crate::{actionbar::NoteAction, images::ImageType, timeline::TimelineKind};
|
use crate::{actionbar::NoteAction, images::ImageType, timeline::TimelineKind};
|
||||||
@@ -8,11 +8,11 @@ use egui::{Color32, Hyperlink, Image, RichText};
|
|||||||
use nostrdb::{BlockType, Mention, Ndb, Note, NoteKey, Transaction};
|
use nostrdb::{BlockType, Mention, Ndb, Note, NoteKey, Transaction};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
|
|
||||||
use notedeck::{MediaCache, NoteCache};
|
use notedeck::{Images, NoteCache};
|
||||||
|
|
||||||
pub struct NoteContents<'a> {
|
pub struct NoteContents<'a> {
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
txn: &'a Transaction,
|
txn: &'a Transaction,
|
||||||
note: &'a Note<'a>,
|
note: &'a Note<'a>,
|
||||||
@@ -22,9 +22,10 @@ pub struct NoteContents<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> NoteContents<'a> {
|
impl<'a> NoteContents<'a> {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
txn: &'a Transaction,
|
txn: &'a Transaction,
|
||||||
note: &'a Note,
|
note: &'a Note,
|
||||||
@@ -72,7 +73,7 @@ pub fn render_note_preview(
|
|||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
ndb: &Ndb,
|
ndb: &Ndb,
|
||||||
note_cache: &mut NoteCache,
|
note_cache: &mut NoteCache,
|
||||||
img_cache: &mut MediaCache,
|
img_cache: &mut Images,
|
||||||
txn: &Transaction,
|
txn: &Transaction,
|
||||||
id: &[u8; 32],
|
id: &[u8; 32],
|
||||||
parent: NoteKey,
|
parent: NoteKey,
|
||||||
@@ -134,7 +135,7 @@ fn is_image_link(url: &str) -> bool {
|
|||||||
fn render_note_contents(
|
fn render_note_contents(
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
ndb: &Ndb,
|
ndb: &Ndb,
|
||||||
img_cache: &mut MediaCache,
|
img_cache: &mut Images,
|
||||||
note_cache: &mut NoteCache,
|
note_cache: &mut NoteCache,
|
||||||
txn: &Transaction,
|
txn: &Transaction,
|
||||||
note: &Note,
|
note: &Note,
|
||||||
@@ -279,7 +280,7 @@ fn rot13(input: &str) -> String {
|
|||||||
|
|
||||||
fn image_carousel(
|
fn image_carousel(
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
img_cache: &mut MediaCache,
|
img_cache: &mut Images,
|
||||||
images: Vec<String>,
|
images: Vec<String>,
|
||||||
carousel_id: egui::Id,
|
carousel_id: egui::Id,
|
||||||
) {
|
) {
|
||||||
@@ -295,7 +296,7 @@ fn image_carousel(
|
|||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
for image in images {
|
for image in images {
|
||||||
render_media_cache(
|
render_images(
|
||||||
ui,
|
ui,
|
||||||
img_cache,
|
img_cache,
|
||||||
&image,
|
&image,
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ use egui::emath::{pos2, Vec2};
|
|||||||
use egui::{Id, Label, Pos2, Rect, Response, RichText, Sense};
|
use egui::{Id, Label, Pos2, Rect, Response, RichText, Sense};
|
||||||
use enostr::{NoteId, Pubkey};
|
use enostr::{NoteId, Pubkey};
|
||||||
use nostrdb::{Ndb, Note, NoteKey, Transaction};
|
use nostrdb::{Ndb, Note, NoteKey, Transaction};
|
||||||
use notedeck::{CachedNote, MediaCache, NoteCache, NotedeckTextStyle};
|
use notedeck::{CachedNote, Images, NoteCache, NotedeckTextStyle};
|
||||||
|
|
||||||
use super::profile::preview::one_line_display_name_widget;
|
use super::profile::preview::one_line_display_name_widget;
|
||||||
|
|
||||||
pub struct NoteView<'a> {
|
pub struct NoteView<'a> {
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
parent: Option<NoteKey>,
|
parent: Option<NoteKey>,
|
||||||
note: &'a nostrdb::Note<'a>,
|
note: &'a nostrdb::Note<'a>,
|
||||||
flags: NoteOptions,
|
flags: NoteOptions,
|
||||||
@@ -74,7 +74,7 @@ impl<'a> NoteView<'a> {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
note: &'a nostrdb::Note<'a>,
|
note: &'a nostrdb::Note<'a>,
|
||||||
mut flags: NoteOptions,
|
mut flags: NoteOptions,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use crate::draft::{Draft, Drafts, MentionHint};
|
|||||||
use crate::media_upload::{nostrbuild_nip96_upload, MediaPath};
|
use crate::media_upload::{nostrbuild_nip96_upload, MediaPath};
|
||||||
use crate::post::{downcast_post_buffer, MentionType, NewPost};
|
use crate::post::{downcast_post_buffer, MentionType, NewPost};
|
||||||
use crate::profile::get_display_name;
|
use crate::profile::get_display_name;
|
||||||
use crate::ui::images::render_media_cache;
|
use crate::ui::images::render_images;
|
||||||
use crate::ui::search_results::SearchResultsView;
|
use crate::ui::search_results::SearchResultsView;
|
||||||
use crate::ui::{self, note::NoteOptions, Preview, PreviewConfig};
|
use crate::ui::{self, note::NoteOptions, Preview, PreviewConfig};
|
||||||
use crate::Result;
|
use crate::Result;
|
||||||
@@ -13,7 +13,7 @@ use egui::{vec2, Frame, Layout, Margin, Pos2, ScrollArea, Sense, TextBuffer};
|
|||||||
use enostr::{FilledKeypair, FullKeypair, NoteId, Pubkey, RelayPool};
|
use enostr::{FilledKeypair, FullKeypair, NoteId, Pubkey, RelayPool};
|
||||||
use nostrdb::{Ndb, Transaction};
|
use nostrdb::{Ndb, Transaction};
|
||||||
|
|
||||||
use notedeck::{get_texture, MediaCache, NoteCache};
|
use notedeck::{get_texture, Images, NoteCache};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use super::contents::render_note_preview;
|
use super::contents::render_note_preview;
|
||||||
@@ -22,7 +22,7 @@ pub struct PostView<'a> {
|
|||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
draft: &'a mut Draft,
|
draft: &'a mut Draft,
|
||||||
post_type: PostType,
|
post_type: PostType,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
id_source: Option<egui::Id>,
|
id_source: Option<egui::Id>,
|
||||||
@@ -88,7 +88,7 @@ impl<'a> PostView<'a> {
|
|||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
draft: &'a mut Draft,
|
draft: &'a mut Draft,
|
||||||
post_type: PostType,
|
post_type: PostType,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
@@ -384,7 +384,8 @@ impl<'a> PostView<'a> {
|
|||||||
} else {
|
} else {
|
||||||
(300, 300)
|
(300, 300)
|
||||||
};
|
};
|
||||||
render_media_cache(
|
|
||||||
|
render_images(
|
||||||
ui,
|
ui,
|
||||||
self.img_cache,
|
self.img_cache,
|
||||||
&media.url,
|
&media.url,
|
||||||
@@ -393,7 +394,7 @@ impl<'a> PostView<'a> {
|
|||||||
ui.spinner();
|
ui.spinner();
|
||||||
},
|
},
|
||||||
|_, e| {
|
|_, e| {
|
||||||
self.draft.upload_errors.push(e.clone());
|
self.draft.upload_errors.push(e.to_string());
|
||||||
error!("{e}");
|
error!("{e}");
|
||||||
},
|
},
|
||||||
|ui, _, renderable_media| {
|
|ui, _, renderable_media| {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use enostr::{FilledKeypair, NoteId};
|
use enostr::{FilledKeypair, NoteId};
|
||||||
use nostrdb::Ndb;
|
use nostrdb::Ndb;
|
||||||
use notedeck::{MediaCache, NoteCache};
|
use notedeck::{Images, NoteCache};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
draft::Draft,
|
draft::Draft,
|
||||||
@@ -13,7 +13,7 @@ pub struct QuoteRepostView<'a> {
|
|||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
draft: &'a mut Draft,
|
draft: &'a mut Draft,
|
||||||
quoting_note: &'a nostrdb::Note<'a>,
|
quoting_note: &'a nostrdb::Note<'a>,
|
||||||
id_source: Option<egui::Id>,
|
id_source: Option<egui::Id>,
|
||||||
@@ -27,7 +27,7 @@ impl<'a> QuoteRepostView<'a> {
|
|||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
draft: &'a mut Draft,
|
draft: &'a mut Draft,
|
||||||
quoting_note: &'a nostrdb::Note<'a>,
|
quoting_note: &'a nostrdb::Note<'a>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ use crate::ui::note::{NoteOptions, PostResponse, PostType};
|
|||||||
use enostr::{FilledKeypair, NoteId};
|
use enostr::{FilledKeypair, NoteId};
|
||||||
use nostrdb::Ndb;
|
use nostrdb::Ndb;
|
||||||
|
|
||||||
use notedeck::{MediaCache, NoteCache};
|
use notedeck::{Images, NoteCache};
|
||||||
|
|
||||||
pub struct PostReplyView<'a> {
|
pub struct PostReplyView<'a> {
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
draft: &'a mut Draft,
|
draft: &'a mut Draft,
|
||||||
note: &'a nostrdb::Note<'a>,
|
note: &'a nostrdb::Note<'a>,
|
||||||
id_source: Option<egui::Id>,
|
id_source: Option<egui::Id>,
|
||||||
@@ -25,7 +25,7 @@ impl<'a> PostReplyView<'a> {
|
|||||||
poster: FilledKeypair<'a>,
|
poster: FilledKeypair<'a>,
|
||||||
draft: &'a mut Draft,
|
draft: &'a mut Draft,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
note: &'a nostrdb::Note<'a>,
|
note: &'a nostrdb::Note<'a>,
|
||||||
inner_rect: egui::Rect,
|
inner_rect: egui::Rect,
|
||||||
note_options: NoteOptions,
|
note_options: NoteOptions,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use egui::{Label, RichText, Sense};
|
use egui::{Label, RichText, Sense};
|
||||||
use nostrdb::{Ndb, Note, NoteReply, Transaction};
|
use nostrdb::{Ndb, Note, NoteReply, Transaction};
|
||||||
use notedeck::{MediaCache, NoteCache};
|
use notedeck::{Images, NoteCache};
|
||||||
|
|
||||||
#[must_use = "Please handle the resulting note action"]
|
#[must_use = "Please handle the resulting note action"]
|
||||||
pub fn reply_desc(
|
pub fn reply_desc(
|
||||||
@@ -12,7 +12,7 @@ pub fn reply_desc(
|
|||||||
txn: &Transaction,
|
txn: &Transaction,
|
||||||
note_reply: &NoteReply,
|
note_reply: &NoteReply,
|
||||||
ndb: &Ndb,
|
ndb: &Ndb,
|
||||||
img_cache: &mut MediaCache,
|
img_cache: &mut Images,
|
||||||
note_cache: &mut NoteCache,
|
note_cache: &mut NoteCache,
|
||||||
note_options: NoteOptions,
|
note_options: NoteOptions,
|
||||||
) -> Option<NoteAction> {
|
) -> Option<NoteAction> {
|
||||||
@@ -29,7 +29,7 @@ pub fn reply_desc(
|
|||||||
// note link renderer helper
|
// note link renderer helper
|
||||||
let note_link = |ui: &mut egui::Ui,
|
let note_link = |ui: &mut egui::Ui,
|
||||||
note_cache: &mut NoteCache,
|
note_cache: &mut NoteCache,
|
||||||
img_cache: &mut MediaCache,
|
img_cache: &mut Images,
|
||||||
text: &str,
|
text: &str,
|
||||||
note: &Note<'_>| {
|
note: &Note<'_>| {
|
||||||
let r = ui.add(
|
let r = ui.add(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use core::f32;
|
use core::f32;
|
||||||
|
|
||||||
use egui::{vec2, Button, Layout, Margin, RichText, Rounding, ScrollArea, TextEdit};
|
use egui::{vec2, Button, Layout, Margin, RichText, Rounding, ScrollArea, TextEdit};
|
||||||
use notedeck::{MediaCache, NotedeckTextStyle};
|
use notedeck::{Images, NotedeckTextStyle};
|
||||||
|
|
||||||
use crate::{colors, profile_state::ProfileState};
|
use crate::{colors, profile_state::ProfileState};
|
||||||
|
|
||||||
@@ -9,11 +9,11 @@ use super::{banner, unwrap_profile_url, ProfilePic};
|
|||||||
|
|
||||||
pub struct EditProfileView<'a> {
|
pub struct EditProfileView<'a> {
|
||||||
state: &'a mut ProfileState,
|
state: &'a mut ProfileState,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> EditProfileView<'a> {
|
impl<'a> EditProfileView<'a> {
|
||||||
pub fn new(state: &'a mut ProfileState, img_cache: &'a mut MediaCache) -> Self {
|
pub fn new(state: &'a mut ProfileState, img_cache: &'a mut Images) -> Self {
|
||||||
Self { state, img_cache }
|
Self { state, img_cache }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use crate::{
|
|||||||
NostrName,
|
NostrName,
|
||||||
};
|
};
|
||||||
|
|
||||||
use notedeck::{Accounts, MediaCache, MuteFun, NoteCache, NotedeckTextStyle, UnknownIds};
|
use notedeck::{Accounts, Images, MuteFun, NoteCache, NotedeckTextStyle, UnknownIds};
|
||||||
|
|
||||||
pub struct ProfileView<'a> {
|
pub struct ProfileView<'a> {
|
||||||
pubkey: &'a Pubkey,
|
pubkey: &'a Pubkey,
|
||||||
@@ -33,7 +33,7 @@ pub struct ProfileView<'a> {
|
|||||||
note_options: NoteOptions,
|
note_options: NoteOptions,
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
unknown_ids: &'a mut UnknownIds,
|
unknown_ids: &'a mut UnknownIds,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ impl<'a> ProfileView<'a> {
|
|||||||
timeline_cache: &'a mut TimelineCache,
|
timeline_cache: &'a mut TimelineCache,
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
unknown_ids: &'a mut UnknownIds,
|
unknown_ids: &'a mut UnknownIds,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
note_options: NoteOptions,
|
note_options: NoteOptions,
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
use crate::images::ImageType;
|
use crate::images::ImageType;
|
||||||
use crate::ui::images::render_media_cache;
|
use crate::ui::images::render_images;
|
||||||
use crate::ui::{Preview, PreviewConfig};
|
use crate::ui::{Preview, PreviewConfig};
|
||||||
use egui::{vec2, Sense, Stroke, TextureHandle};
|
use egui::{vec2, Sense, Stroke, TextureHandle};
|
||||||
use nostrdb::{Ndb, Transaction};
|
use nostrdb::{Ndb, Transaction};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
use notedeck::{AppContext, MediaCache};
|
use notedeck::{AppContext, Images};
|
||||||
|
|
||||||
pub struct ProfilePic<'cache, 'url> {
|
pub struct ProfilePic<'cache, 'url> {
|
||||||
cache: &'cache mut MediaCache,
|
cache: &'cache mut Images,
|
||||||
url: &'url str,
|
url: &'url str,
|
||||||
size: f32,
|
size: f32,
|
||||||
border: Option<Stroke>,
|
border: Option<Stroke>,
|
||||||
@@ -21,7 +21,7 @@ impl egui::Widget for ProfilePic<'_, '_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'cache, 'url> ProfilePic<'cache, 'url> {
|
impl<'cache, 'url> ProfilePic<'cache, 'url> {
|
||||||
pub fn new(cache: &'cache mut MediaCache, url: &'url str) -> Self {
|
pub fn new(cache: &'cache mut Images, url: &'url str) -> Self {
|
||||||
let size = Self::default_size();
|
let size = Self::default_size();
|
||||||
ProfilePic {
|
ProfilePic {
|
||||||
cache,
|
cache,
|
||||||
@@ -36,7 +36,7 @@ impl<'cache, 'url> ProfilePic<'cache, 'url> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_profile(
|
pub fn from_profile(
|
||||||
cache: &'cache mut MediaCache,
|
cache: &'cache mut Images,
|
||||||
profile: &nostrdb::ProfileRecord<'url>,
|
profile: &nostrdb::ProfileRecord<'url>,
|
||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
profile
|
profile
|
||||||
@@ -81,7 +81,7 @@ impl<'cache, 'url> ProfilePic<'cache, 'url> {
|
|||||||
|
|
||||||
fn render_pfp(
|
fn render_pfp(
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
img_cache: &mut MediaCache,
|
img_cache: &mut Images,
|
||||||
url: &str,
|
url: &str,
|
||||||
ui_size: f32,
|
ui_size: f32,
|
||||||
border: Option<Stroke>,
|
border: Option<Stroke>,
|
||||||
@@ -92,7 +92,7 @@ fn render_pfp(
|
|||||||
// We will want to downsample these so it's not blurry on hi res displays
|
// We will want to downsample these so it's not blurry on hi res displays
|
||||||
let img_size = 128u32;
|
let img_size = 128u32;
|
||||||
|
|
||||||
render_media_cache(
|
render_images(
|
||||||
ui,
|
ui,
|
||||||
img_cache,
|
img_cache,
|
||||||
url,
|
url,
|
||||||
|
|||||||
@@ -4,18 +4,18 @@ use egui::{Frame, Label, RichText, Widget};
|
|||||||
use egui_extras::Size;
|
use egui_extras::Size;
|
||||||
use nostrdb::ProfileRecord;
|
use nostrdb::ProfileRecord;
|
||||||
|
|
||||||
use notedeck::{MediaCache, NotedeckTextStyle, UserAccount};
|
use notedeck::{Images, NotedeckTextStyle, UserAccount};
|
||||||
|
|
||||||
use super::{about_section_widget, banner, display_name_widget, get_display_name, get_profile_url};
|
use super::{about_section_widget, banner, display_name_widget, get_display_name, get_profile_url};
|
||||||
|
|
||||||
pub struct ProfilePreview<'a, 'cache> {
|
pub struct ProfilePreview<'a, 'cache> {
|
||||||
profile: &'a ProfileRecord<'a>,
|
profile: &'a ProfileRecord<'a>,
|
||||||
cache: &'cache mut MediaCache,
|
cache: &'cache mut Images,
|
||||||
banner_height: Size,
|
banner_height: Size,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'cache> ProfilePreview<'a, 'cache> {
|
impl<'a, 'cache> ProfilePreview<'a, 'cache> {
|
||||||
pub fn new(profile: &'a ProfileRecord<'a>, cache: &'cache mut MediaCache) -> Self {
|
pub fn new(profile: &'a ProfileRecord<'a>, cache: &'cache mut Images) -> Self {
|
||||||
let banner_height = Size::exact(80.0);
|
let banner_height = Size::exact(80.0);
|
||||||
ProfilePreview {
|
ProfilePreview {
|
||||||
profile,
|
profile,
|
||||||
@@ -69,14 +69,14 @@ impl egui::Widget for ProfilePreview<'_, '_> {
|
|||||||
|
|
||||||
pub struct SimpleProfilePreview<'a, 'cache> {
|
pub struct SimpleProfilePreview<'a, 'cache> {
|
||||||
profile: Option<&'a ProfileRecord<'a>>,
|
profile: Option<&'a ProfileRecord<'a>>,
|
||||||
cache: &'cache mut MediaCache,
|
cache: &'cache mut Images,
|
||||||
is_nsec: bool,
|
is_nsec: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'cache> SimpleProfilePreview<'a, 'cache> {
|
impl<'a, 'cache> SimpleProfilePreview<'a, 'cache> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
profile: Option<&'a ProfileRecord<'a>>,
|
profile: Option<&'a ProfileRecord<'a>>,
|
||||||
cache: &'cache mut MediaCache,
|
cache: &'cache mut Images,
|
||||||
is_nsec: bool,
|
is_nsec: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
SimpleProfilePreview {
|
SimpleProfilePreview {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use egui::{vec2, FontId, Pos2, Rect, ScrollArea, Vec2b};
|
use egui::{vec2, FontId, Pos2, Rect, ScrollArea, Vec2b};
|
||||||
use nostrdb::{Ndb, ProfileRecord, Transaction};
|
use nostrdb::{Ndb, ProfileRecord, Transaction};
|
||||||
use notedeck::{fonts::get_font_size, MediaCache, NotedeckTextStyle};
|
use notedeck::{fonts::get_font_size, Images, NotedeckTextStyle};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -13,13 +13,13 @@ use super::{profile::get_profile_url, ProfilePic};
|
|||||||
pub struct SearchResultsView<'a> {
|
pub struct SearchResultsView<'a> {
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
txn: &'a Transaction,
|
txn: &'a Transaction,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
results: &'a Vec<&'a [u8; 32]>,
|
results: &'a Vec<&'a [u8; 32]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> SearchResultsView<'a> {
|
impl<'a> SearchResultsView<'a> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
txn: &'a Transaction,
|
txn: &'a Transaction,
|
||||||
results: &'a Vec<&'a [u8; 32]>,
|
results: &'a Vec<&'a [u8; 32]>,
|
||||||
@@ -84,7 +84,7 @@ impl<'a> SearchResultsView<'a> {
|
|||||||
|
|
||||||
fn user_result<'a>(
|
fn user_result<'a>(
|
||||||
profile: &'a ProfileRecord<'_>,
|
profile: &'a ProfileRecord<'_>,
|
||||||
cache: &'a mut MediaCache,
|
cache: &'a mut Images,
|
||||||
index: usize,
|
index: usize,
|
||||||
width: f32,
|
width: f32,
|
||||||
) -> impl egui::Widget + 'a {
|
) -> impl egui::Widget + 'a {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use crate::{
|
|||||||
support::Support,
|
support::Support,
|
||||||
};
|
};
|
||||||
|
|
||||||
use notedeck::{Accounts, MediaCache, NotedeckTextStyle, ThemeHandler, UserAccount};
|
use notedeck::{Accounts, Images, NotedeckTextStyle, ThemeHandler, UserAccount};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE},
|
anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE},
|
||||||
@@ -29,7 +29,7 @@ static ICON_WIDTH: f32 = 40.0;
|
|||||||
|
|
||||||
pub struct DesktopSidePanel<'a> {
|
pub struct DesktopSidePanel<'a> {
|
||||||
ndb: &'a nostrdb::Ndb,
|
ndb: &'a nostrdb::Ndb,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
selected_account: Option<&'a UserAccount>,
|
selected_account: Option<&'a UserAccount>,
|
||||||
decks_cache: &'a DecksCache,
|
decks_cache: &'a DecksCache,
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ impl SidePanelResponse {
|
|||||||
impl<'a> DesktopSidePanel<'a> {
|
impl<'a> DesktopSidePanel<'a> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
ndb: &'a nostrdb::Ndb,
|
ndb: &'a nostrdb::Ndb,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
selected_account: Option<&'a UserAccount>,
|
selected_account: Option<&'a UserAccount>,
|
||||||
decks_cache: &'a DecksCache,
|
decks_cache: &'a DecksCache,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use nostrdb::{Ndb, Transaction};
|
use nostrdb::{Ndb, Transaction};
|
||||||
use notedeck::{MediaCache, MuteFun, NoteCache, RootNoteId, UnknownIds};
|
use notedeck::{Images, MuteFun, NoteCache, RootNoteId, UnknownIds};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use super::timeline::TimelineTabView;
|
use super::timeline::TimelineTabView;
|
||||||
@@ -15,7 +15,7 @@ pub struct ThreadView<'a> {
|
|||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
unknown_ids: &'a mut UnknownIds,
|
unknown_ids: &'a mut UnknownIds,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
selected_note_id: &'a [u8; 32],
|
selected_note_id: &'a [u8; 32],
|
||||||
note_options: NoteOptions,
|
note_options: NoteOptions,
|
||||||
id_source: egui::Id,
|
id_source: egui::Id,
|
||||||
@@ -29,7 +29,7 @@ impl<'a> ThreadView<'a> {
|
|||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
unknown_ids: &'a mut UnknownIds,
|
unknown_ids: &'a mut UnknownIds,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
selected_note_id: &'a [u8; 32],
|
selected_note_id: &'a [u8; 32],
|
||||||
note_options: NoteOptions,
|
note_options: NoteOptions,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use egui::{vec2, Direction, Layout, Pos2, Stroke};
|
|||||||
use egui_tabs::TabColor;
|
use egui_tabs::TabColor;
|
||||||
use nostrdb::{Ndb, Transaction};
|
use nostrdb::{Ndb, Transaction};
|
||||||
use notedeck::note::root_note_id_from_selected_id;
|
use notedeck::note::root_note_id_from_selected_id;
|
||||||
use notedeck::{MediaCache, MuteFun, NoteCache};
|
use notedeck::{Images, MuteFun, NoteCache};
|
||||||
use tracing::{error, warn};
|
use tracing::{error, warn};
|
||||||
|
|
||||||
use super::anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE};
|
use super::anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE};
|
||||||
@@ -22,19 +22,20 @@ pub struct TimelineView<'a> {
|
|||||||
timeline_cache: &'a mut TimelineCache,
|
timeline_cache: &'a mut TimelineCache,
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
note_options: NoteOptions,
|
note_options: NoteOptions,
|
||||||
reverse: bool,
|
reverse: bool,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TimelineView<'a> {
|
impl<'a> TimelineView<'a> {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
timeline_id: &'a TimelineKind,
|
timeline_id: &'a TimelineKind,
|
||||||
timeline_cache: &'a mut TimelineCache,
|
timeline_cache: &'a mut TimelineCache,
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
note_options: NoteOptions,
|
note_options: NoteOptions,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
) -> TimelineView<'a> {
|
) -> TimelineView<'a> {
|
||||||
@@ -78,7 +79,7 @@ fn timeline_ui(
|
|||||||
timeline_id: &TimelineKind,
|
timeline_id: &TimelineKind,
|
||||||
timeline_cache: &mut TimelineCache,
|
timeline_cache: &mut TimelineCache,
|
||||||
note_cache: &mut NoteCache,
|
note_cache: &mut NoteCache,
|
||||||
img_cache: &mut MediaCache,
|
img_cache: &mut Images,
|
||||||
reversed: bool,
|
reversed: bool,
|
||||||
note_options: NoteOptions,
|
note_options: NoteOptions,
|
||||||
is_muted: &MuteFun,
|
is_muted: &MuteFun,
|
||||||
@@ -321,7 +322,7 @@ pub struct TimelineTabView<'a> {
|
|||||||
txn: &'a Transaction,
|
txn: &'a Transaction,
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +335,7 @@ impl<'a> TimelineTabView<'a> {
|
|||||||
txn: &'a Transaction,
|
txn: &'a Transaction,
|
||||||
ndb: &'a Ndb,
|
ndb: &'a Ndb,
|
||||||
note_cache: &'a mut NoteCache,
|
note_cache: &'a mut NoteCache,
|
||||||
img_cache: &'a mut MediaCache,
|
img_cache: &'a mut Images,
|
||||||
is_muted: &'a MuteFun,
|
is_muted: &'a MuteFun,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
Reference in New Issue
Block a user