notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 4886f03967fef564c3df7fa133682223e72d2a4d
parent 7eef74258e2657c0efce268c39999826d7143fa2
Author: kernelkind <kernelkind@gmail.com>
Date:   Sat, 22 Nov 2025 20:10:49 -0700

tmp(refactor): TextureState -> TextureStateOld

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Mcrates/notedeck/src/imgcache.rs | 20+++++++++++---------
Mcrates/notedeck/src/lib.rs | 2+-
Mcrates/notedeck/src/media/gif.rs | 4++--
Mcrates/notedeck_columns/src/ui/note/post.rs | 6+++---
Mcrates/notedeck_ui/src/profile/picture.rs | 6+++---
5 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/crates/notedeck/src/imgcache.rs b/crates/notedeck/src/imgcache.rs @@ -45,7 +45,7 @@ impl TexturesCache { &mut self, url: &str, closure: impl FnOnce() -> Promise<Option<Result<TexturedImage>>>, - ) -> TextureState<'_> { + ) -> TextureStateOld<'_> { let internal = self.handle_and_get_state_internal(url, false, closure); internal.into() @@ -141,25 +141,27 @@ pub enum LoadableTextureState<'a> { Loaded(&'a mut TexturedImage), } -pub enum TextureState<'a> { +pub enum TextureStateOld<'a> { Pending, Error(&'a crate::Error), Loaded(&'a mut TexturedImage), } -impl<'a> TextureState<'a> { +impl<'a> TextureStateOld<'a> { pub fn is_loaded(&self) -> bool { matches!(self, Self::Loaded(_)) } } -impl<'a> From<&'a mut TextureStateInternal> for TextureState<'a> { +impl<'a> From<&'a mut TextureStateInternal> for TextureStateOld<'a> { fn from(value: &'a mut TextureStateInternal) -> Self { match value { - TextureStateInternal::Pending(_) => TextureState::Pending, - TextureStateInternal::Error(error) => TextureState::Error(error), - TextureStateInternal::Loading(textured_image) => TextureState::Loaded(textured_image), - TextureStateInternal::Loaded(textured_image) => TextureState::Loaded(textured_image), + TextureStateInternal::Pending(_) => TextureStateOld::Pending, + TextureStateInternal::Error(error) => TextureStateOld::Error(error), + TextureStateInternal::Loading(textured_image) => { + TextureStateOld::Loaded(textured_image) + } + TextureStateInternal::Loaded(textured_image) => TextureStateOld::Loaded(textured_image), } } } @@ -569,6 +571,6 @@ pub fn get_render_state<'a>( } pub struct RenderState<'a> { - pub texture_state: TextureState<'a>, + pub texture_state: TextureStateOld<'a>, pub gifs: &'a mut GifStateMap, } diff --git a/crates/notedeck/src/lib.rs b/crates/notedeck/src/lib.rs @@ -55,7 +55,7 @@ pub use fonts::NamedFontFamily; pub use i18n::{CacheStats, FluentArgs, FluentValue, LanguageIdentifier, Localization}; pub use imgcache::{ get_render_state, Animation, GifState, GifStateMap, ImageFrame, Images, LatestTexture, - LoadableTextureState, MediaCache, MediaCacheType, RenderState, TextureFrame, TextureState, + LoadableTextureState, MediaCache, MediaCacheType, RenderState, TextureFrame, TextureStateOld, TexturedImage, TexturesCache, }; pub use jobs::{ diff --git a/crates/notedeck/src/media/gif.rs b/crates/notedeck/src/media/gif.rs @@ -5,7 +5,7 @@ use std::{ use crate::media::AnimationMode; use crate::Animation; -use crate::{GifState, GifStateMap, TextureState, TexturedImage, TexturesCache}; +use crate::{GifState, GifStateMap, TextureStateOld, TexturedImage, TexturesCache}; use egui::TextureHandle; use std::time::Duration; @@ -18,7 +18,7 @@ pub fn ensure_latest_texture_from_cache( ) -> Option<TextureHandle> { let tstate = textures.cache.get_mut(url)?; - let TextureState::Loaded(img) = tstate.into() else { + let TextureStateOld::Loaded(img) = tstate.into() else { return None; }; diff --git a/crates/notedeck_columns/src/ui/note/post.rs b/crates/notedeck_columns/src/ui/note/post.rs @@ -649,14 +649,14 @@ fn render_post_view_media( animation_mode: AnimationMode, ) { match render_state.texture_state { - notedeck::TextureState::Pending => { + notedeck::TextureStateOld::Pending => { ui.spinner(); } - notedeck::TextureState::Error(e) => { + notedeck::TextureStateOld::Error(e) => { upload_errors.push(e.to_string()); error!("{e}"); } - notedeck::TextureState::Loaded(renderable_media) => { + notedeck::TextureStateOld::Loaded(renderable_media) => { let max_size = 300; let size = if width > max_size || height > max_size { PixelDimensions { x: 300, y: 300 } diff --git a/crates/notedeck_ui/src/profile/picture.rs b/crates/notedeck_ui/src/profile/picture.rs @@ -143,11 +143,11 @@ fn render_pfp( ); match cur_state.texture_state { - notedeck::TextureState::Pending => { + notedeck::TextureStateOld::Pending => { profiling::scope!("Render pending"); egui::InnerResponse::new(None, paint_circle(ui, ui_size, border, sense)) } - notedeck::TextureState::Error(e) => { + notedeck::TextureStateOld::Error(e) => { profiling::scope!("Render error"); let r = paint_circle(ui, ui_size, border, sense); show_one_error_message(ui, &format!("Failed to fetch profile at url {url}: {e}")); @@ -160,7 +160,7 @@ fn render_pfp( r, ) } - notedeck::TextureState::Loaded(textured_image) => { + notedeck::TextureStateOld::Loaded(textured_image) => { profiling::scope!("Render loaded"); let texture_handle = ensure_latest_texture(ui, url, cur_state.gifs, textured_image, animation_mode);