migrate to using Images instead of MediaCache directly

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-02-18 19:42:17 -05:00
parent 75a352a86f
commit 33fdf647e3
27 changed files with 101 additions and 106 deletions

View File

@@ -1,7 +1,7 @@
use core::f32;
use egui::{vec2, Button, Layout, Margin, RichText, Rounding, ScrollArea, TextEdit};
use notedeck::{MediaCache, NotedeckTextStyle};
use notedeck::{Images, 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 MediaCache,
img_cache: &'a mut Images,
}
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 }
}

View File

@@ -23,7 +23,7 @@ use crate::{
NostrName,
};
use notedeck::{Accounts, MediaCache, MuteFun, NoteCache, NotedeckTextStyle, UnknownIds};
use notedeck::{Accounts, Images, 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 MediaCache,
img_cache: &'a mut Images,
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 MediaCache,
img_cache: &'a mut Images,
unknown_ids: &'a mut UnknownIds,
is_muted: &'a MuteFun,
note_options: NoteOptions,

View File

@@ -1,14 +1,14 @@
use crate::images::ImageType;
use crate::ui::images::render_media_cache;
use crate::ui::images::render_images;
use crate::ui::{Preview, PreviewConfig};
use egui::{vec2, Sense, Stroke, TextureHandle};
use nostrdb::{Ndb, Transaction};
use tracing::info;
use notedeck::{AppContext, MediaCache};
use notedeck::{AppContext, Images};
pub struct ProfilePic<'cache, 'url> {
cache: &'cache mut MediaCache,
cache: &'cache mut Images,
url: &'url str,
size: f32,
border: Option<Stroke>,
@@ -21,7 +21,7 @@ impl egui::Widget for ProfilePic<'_, '_> {
}
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();
ProfilePic {
cache,
@@ -36,7 +36,7 @@ impl<'cache, 'url> ProfilePic<'cache, 'url> {
}
pub fn from_profile(
cache: &'cache mut MediaCache,
cache: &'cache mut Images,
profile: &nostrdb::ProfileRecord<'url>,
) -> Option<Self> {
profile
@@ -81,7 +81,7 @@ impl<'cache, 'url> ProfilePic<'cache, 'url> {
fn render_pfp(
ui: &mut egui::Ui,
img_cache: &mut MediaCache,
img_cache: &mut Images,
url: &str,
ui_size: f32,
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
let img_size = 128u32;
render_media_cache(
render_images(
ui,
img_cache,
url,

View File

@@ -4,18 +4,18 @@ use egui::{Frame, Label, RichText, Widget};
use egui_extras::Size;
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};
pub struct ProfilePreview<'a, 'cache> {
profile: &'a ProfileRecord<'a>,
cache: &'cache mut MediaCache,
cache: &'cache mut Images,
banner_height: Size,
}
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);
ProfilePreview {
profile,
@@ -69,14 +69,14 @@ impl egui::Widget for ProfilePreview<'_, '_> {
pub struct SimpleProfilePreview<'a, 'cache> {
profile: Option<&'a ProfileRecord<'a>>,
cache: &'cache mut MediaCache,
cache: &'cache mut Images,
is_nsec: bool,
}
impl<'a, 'cache> SimpleProfilePreview<'a, 'cache> {
pub fn new(
profile: Option<&'a ProfileRecord<'a>>,
cache: &'cache mut MediaCache,
cache: &'cache mut Images,
is_nsec: bool,
) -> Self {
SimpleProfilePreview {