migrate to using Images instead of MediaCache directly
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::ui::images::render_images;
|
||||
use crate::ui::{
|
||||
self,
|
||||
images::render_media_cache,
|
||||
note::{NoteOptions, NoteResponse},
|
||||
};
|
||||
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 tracing::warn;
|
||||
|
||||
use notedeck::{MediaCache, NoteCache};
|
||||
use notedeck::{Images, NoteCache};
|
||||
|
||||
pub struct NoteContents<'a> {
|
||||
ndb: &'a Ndb,
|
||||
img_cache: &'a mut MediaCache,
|
||||
img_cache: &'a mut Images,
|
||||
note_cache: &'a mut NoteCache,
|
||||
txn: &'a Transaction,
|
||||
note: &'a Note<'a>,
|
||||
@@ -22,9 +22,10 @@ pub struct NoteContents<'a> {
|
||||
}
|
||||
|
||||
impl<'a> NoteContents<'a> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
ndb: &'a Ndb,
|
||||
img_cache: &'a mut MediaCache,
|
||||
img_cache: &'a mut Images,
|
||||
note_cache: &'a mut NoteCache,
|
||||
txn: &'a Transaction,
|
||||
note: &'a Note,
|
||||
@@ -72,7 +73,7 @@ pub fn render_note_preview(
|
||||
ui: &mut egui::Ui,
|
||||
ndb: &Ndb,
|
||||
note_cache: &mut NoteCache,
|
||||
img_cache: &mut MediaCache,
|
||||
img_cache: &mut Images,
|
||||
txn: &Transaction,
|
||||
id: &[u8; 32],
|
||||
parent: NoteKey,
|
||||
@@ -134,7 +135,7 @@ fn is_image_link(url: &str) -> bool {
|
||||
fn render_note_contents(
|
||||
ui: &mut egui::Ui,
|
||||
ndb: &Ndb,
|
||||
img_cache: &mut MediaCache,
|
||||
img_cache: &mut Images,
|
||||
note_cache: &mut NoteCache,
|
||||
txn: &Transaction,
|
||||
note: &Note,
|
||||
@@ -279,7 +280,7 @@ fn rot13(input: &str) -> String {
|
||||
|
||||
fn image_carousel(
|
||||
ui: &mut egui::Ui,
|
||||
img_cache: &mut MediaCache,
|
||||
img_cache: &mut Images,
|
||||
images: Vec<String>,
|
||||
carousel_id: egui::Id,
|
||||
) {
|
||||
@@ -295,7 +296,7 @@ fn image_carousel(
|
||||
.show(ui, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
for image in images {
|
||||
render_media_cache(
|
||||
render_images(
|
||||
ui,
|
||||
img_cache,
|
||||
&image,
|
||||
|
||||
@@ -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, MediaCache, NoteCache, NotedeckTextStyle};
|
||||
use notedeck::{CachedNote, Images, 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 MediaCache,
|
||||
img_cache: &'a mut Images,
|
||||
parent: Option<NoteKey>,
|
||||
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 MediaCache,
|
||||
img_cache: &'a mut Images,
|
||||
note: &'a nostrdb::Note<'a>,
|
||||
mut flags: NoteOptions,
|
||||
) -> Self {
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::draft::{Draft, Drafts, MentionHint};
|
||||
use crate::media_upload::{nostrbuild_nip96_upload, MediaPath};
|
||||
use crate::post::{downcast_post_buffer, MentionType, NewPost};
|
||||
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::{self, note::NoteOptions, Preview, PreviewConfig};
|
||||
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 nostrdb::{Ndb, Transaction};
|
||||
|
||||
use notedeck::{get_texture, MediaCache, NoteCache};
|
||||
use notedeck::{get_texture, Images, 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 MediaCache,
|
||||
img_cache: &'a mut Images,
|
||||
note_cache: &'a mut NoteCache,
|
||||
poster: FilledKeypair<'a>,
|
||||
id_source: Option<egui::Id>,
|
||||
@@ -88,7 +88,7 @@ impl<'a> PostView<'a> {
|
||||
ndb: &'a Ndb,
|
||||
draft: &'a mut Draft,
|
||||
post_type: PostType,
|
||||
img_cache: &'a mut MediaCache,
|
||||
img_cache: &'a mut Images,
|
||||
note_cache: &'a mut NoteCache,
|
||||
poster: FilledKeypair<'a>,
|
||||
inner_rect: egui::Rect,
|
||||
@@ -384,7 +384,8 @@ impl<'a> PostView<'a> {
|
||||
} else {
|
||||
(300, 300)
|
||||
};
|
||||
render_media_cache(
|
||||
|
||||
render_images(
|
||||
ui,
|
||||
self.img_cache,
|
||||
&media.url,
|
||||
@@ -393,7 +394,7 @@ impl<'a> PostView<'a> {
|
||||
ui.spinner();
|
||||
},
|
||||
|_, e| {
|
||||
self.draft.upload_errors.push(e.clone());
|
||||
self.draft.upload_errors.push(e.to_string());
|
||||
error!("{e}");
|
||||
},
|
||||
|ui, _, renderable_media| {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use enostr::{FilledKeypair, NoteId};
|
||||
use nostrdb::Ndb;
|
||||
use notedeck::{MediaCache, NoteCache};
|
||||
use notedeck::{Images, 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 MediaCache,
|
||||
img_cache: &'a mut Images,
|
||||
draft: &'a mut Draft,
|
||||
quoting_note: &'a nostrdb::Note<'a>,
|
||||
id_source: Option<egui::Id>,
|
||||
@@ -27,7 +27,7 @@ impl<'a> QuoteRepostView<'a> {
|
||||
ndb: &'a Ndb,
|
||||
poster: FilledKeypair<'a>,
|
||||
note_cache: &'a mut NoteCache,
|
||||
img_cache: &'a mut MediaCache,
|
||||
img_cache: &'a mut Images,
|
||||
draft: &'a mut Draft,
|
||||
quoting_note: &'a nostrdb::Note<'a>,
|
||||
inner_rect: egui::Rect,
|
||||
|
||||
@@ -4,13 +4,13 @@ use crate::ui::note::{NoteOptions, PostResponse, PostType};
|
||||
use enostr::{FilledKeypair, NoteId};
|
||||
use nostrdb::Ndb;
|
||||
|
||||
use notedeck::{MediaCache, NoteCache};
|
||||
use notedeck::{Images, NoteCache};
|
||||
|
||||
pub struct PostReplyView<'a> {
|
||||
ndb: &'a Ndb,
|
||||
poster: FilledKeypair<'a>,
|
||||
note_cache: &'a mut NoteCache,
|
||||
img_cache: &'a mut MediaCache,
|
||||
img_cache: &'a mut Images,
|
||||
draft: &'a mut Draft,
|
||||
note: &'a nostrdb::Note<'a>,
|
||||
id_source: Option<egui::Id>,
|
||||
@@ -25,7 +25,7 @@ impl<'a> PostReplyView<'a> {
|
||||
poster: FilledKeypair<'a>,
|
||||
draft: &'a mut Draft,
|
||||
note_cache: &'a mut NoteCache,
|
||||
img_cache: &'a mut MediaCache,
|
||||
img_cache: &'a mut Images,
|
||||
note: &'a nostrdb::Note<'a>,
|
||||
inner_rect: egui::Rect,
|
||||
note_options: NoteOptions,
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::{
|
||||
};
|
||||
use egui::{Label, RichText, Sense};
|
||||
use nostrdb::{Ndb, Note, NoteReply, Transaction};
|
||||
use notedeck::{MediaCache, NoteCache};
|
||||
use notedeck::{Images, 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 MediaCache,
|
||||
img_cache: &mut Images,
|
||||
note_cache: &mut NoteCache,
|
||||
note_options: NoteOptions,
|
||||
) -> Option<NoteAction> {
|
||||
@@ -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 MediaCache,
|
||||
img_cache: &mut Images,
|
||||
text: &str,
|
||||
note: &Note<'_>| {
|
||||
let r = ui.add(
|
||||
|
||||
Reference in New Issue
Block a user