feat: implement Phase 11 — inline photo viewing with ratatui-image
Add feature-gated (`images`) inline photo support: - New types: MediaInfo, PhotoInfo, PhotoDownloadState, ImagesConfig - Media module: ImageCache (LRU filesystem cache), ImageRenderer (terminal protocol detection) - Photo metadata extraction from TDLib MessagePhoto with download_file() API - ViewImage command (v/м) to toggle photo expand/collapse in message selection - Two-pass UI rendering: placeholder lines in message bubbles + StatefulImage overlay - Collapse all expanded photos on Esc (exit selection mode) Dependencies: ratatui-image 8.1, image 0.25 (optional, behind `images` feature flag) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -85,6 +85,11 @@ pub struct App<T: TdClientTrait = TdClient> {
|
||||
// Typing indicator
|
||||
/// Время последней отправки typing status (для throttling)
|
||||
pub last_typing_sent: Option<std::time::Instant>,
|
||||
// Image support
|
||||
#[cfg(feature = "images")]
|
||||
pub image_renderer: Option<crate::media::image_renderer::ImageRenderer>,
|
||||
#[cfg(feature = "images")]
|
||||
pub image_cache: Option<crate::media::cache::ImageCache>,
|
||||
}
|
||||
|
||||
impl<T: TdClientTrait> App<T> {
|
||||
@@ -104,6 +109,13 @@ impl<T: TdClientTrait> App<T> {
|
||||
let mut state = ListState::default();
|
||||
state.select(Some(0));
|
||||
|
||||
#[cfg(feature = "images")]
|
||||
let image_cache = Some(crate::media::cache::ImageCache::new(
|
||||
config.images.cache_size_mb,
|
||||
));
|
||||
#[cfg(feature = "images")]
|
||||
let image_renderer = crate::media::image_renderer::ImageRenderer::new();
|
||||
|
||||
App {
|
||||
config,
|
||||
screen: AppScreen::Loading,
|
||||
@@ -126,6 +138,10 @@ impl<T: TdClientTrait> App<T> {
|
||||
search_query: String::new(),
|
||||
needs_redraw: true,
|
||||
last_typing_sent: None,
|
||||
#[cfg(feature = "images")]
|
||||
image_renderer,
|
||||
#[cfg(feature = "images")]
|
||||
image_cache,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user