Commit 5cf88f6107

5cf88f61077ede664a97fc338119658683807766

parent: c0980df71a

Unregistered key

vaw <git@nlih.de> · 2026-08-31 23:57 UTC
committer: <noreply@github.com>

Image Preview improvements (#653)

Layout: unified · split

Cargo.lock +4 −2
@@ -2582,6 +2582,7 @@ dependencies = [
25822582 "ravif",
25832583 "rayon",
25842584 "rgb",
2585 "serde",
25852586 "tiff",
25862587 "zune-core",
25872588 "zune-jpeg",
@@ -4472,13 +4473,14 @@ dependencies = [
44724473
44734474[[package]]
44744475name = "ratatui-image"
4475version = "8.1.1"
4476version = "9.0.0"
44764477source = "registry+https://github.com/rust-lang/crates.io-index"
4477checksum = "3ecc67e9f7d0ac69e0f712f58b1a9d5a04d8daeeb3628f4d6b67580abb88b7cb"
4478checksum = "5dbebe428e366c230b2251c7091f2a56ec2bf818d96cdc807f6474428ee09040"
44784479dependencies = [
44794480 "base64-simd",
44804481 "icy_sixel",
44814482 "image",
4483 "pkg-config",
44824484 "rand 0.8.6",
44834485 "ratatui",
44844486 "rustix 0.38.44",
Cargo.toml +8 −2
@@ -21,6 +21,8 @@ desktop = ["dep:notify-rust", "modalkit/clipboard"]
2121max_level_warn = ["tracing/max_level_warn"]
2222max_level_error = ["tracing/max_level_error"]
2323max_level_off = ["tracing/max_level_off"]
24chafa-dyn = ["ratatui-image/chafa-dyn"]
25chafa-static = ["ratatui-image/chafa-static"]
2426
2527[build-dependencies.vergen-gitcl]
2628version = "9"
@@ -43,7 +45,7 @@ gethostname = "1.1"
4345html5ever = "0.39.0"
4446http-serde = "2.1.1"
4547humansize = "2.0.0"
46image = "0.25.6"
48image = {version = "0.25.6", features = ["serde"], default-features = false}
4749libc = "0.2"
4850linkify = "0.11.0"
4951markup5ever_rcdom = "0.39"
@@ -53,7 +55,6 @@ nom = "8.0"
5355open = "5.0.0"
5456rand = "0.10"
5557ratatui = "0.29.0"
56ratatui-image = { version = "8.0", features = ["serde"] }
5758regex = "1.5"
5859rpassword = "7.2"
5960serde = "1.0"
@@ -105,6 +106,11 @@ version = "0.18.0"
105106version = "1.24.1"
106107features = ["macros", "net", "rt-multi-thread", "sync", "time"]
107108
109[dependencies.ratatui-image]
110version = "9.0"
111default-features = false
112features = ["serde", "crossterm", "image-defaults"]
113
108114[dev-dependencies]
109115lazy_static = "1.4.0"
110116pretty_assertions = "1.4.0"
README.md +12 −3
@@ -79,9 +79,18 @@ cargo install --profile release-light --features max_level_error --path .
7979```
8080
8181Add `--no-default-features` if you want to skip desktop integration (e.g.
82clipboard and notifications support) and you would like to link against
83your system's OpenSSL and SQLite instead of using rustls and a bundled
84SQLite.
82clipboard and notifications support) and you would like to link against your
83system's SQLite instead of using a bundled SQLite.
84
85### Crate features
86
87- `bundled`: use bundled SQLite instead of system library (default)
88- `desktop`: enable desktop notifications and clipboard support (default)
89- `max_level_warn`: disable support for more verbose logging than the default `warn` level
90- `max_level_error`: disable support for more verbose logging than the `error` level
91- `max_level_off`: disable all logs at compile time
92- `chafa-dyn`: use [chafa](https://hpjansson.org/chafa/) as a dynamic library for halfblock rendering
93- `chafa-static`: use [chafa](https://hpjansson.org/chafa/) as a static library for halfblock rendering
8594
8695## Installation (via `crates.io`)
8796
config.example.toml +1 −1
@@ -29,7 +29,7 @@ indicator = "only-encrypted"
2929indicator_location = "title|prompt"
3030
3131[settings.image_preview]
32protocol.type = "sixel"
32protocol = { type = "sixel", filter = "Nearest" }
3333size = { "width" = 66, "height" = 10 }
3434
3535[settings.proxy]
docs/iamb.5 +55 −32
@@ -161,37 +161,9 @@ for more details.
161161.It Sy external_edit_file_suffix
162162Suffix to append to temporary file names when using the :editor command. Defaults to .md.
163163.It Sy image_preview
164Enable image previews and configure it.
165An empty object will enable the feature with default settings, omitting it will disable the feature.
166The available fields in this object are:
167.Bl -tag -width Ds
168.It Sy lazy_load
169If
170.Sy true
171(the default), download and render image previews when viewing a message with an image.
172If
173.Sy false ,
174load previews as soon as a message with an image is received.
175.It Sy size
176An optional object with
177.Sy width
178and
179.Sy height
180fields to specify the preview size in cells.
181Defaults to 66 and 10.
182.It Sy protocol
183An optional object to override settings that will normally be guessed automatically:
184.Bl -tag -width Ds
185.It Sy type
186An optional string set to one of the protocol types:
187.Dq Sy sixel ,
188.Dq Sy kitty ,
189and
190.Dq Sy halfblocks .
191.It Sy font_size
192An optional list of two numbers representing font width and height in pixels.
193.El
194.El
164Subsection for configuring image previews. See
165.Sx "IMAGE PREVIEWS"
166for more details.
195167.It Sy log_level
196168Specifies the lowest log level that should be shown.
197169Possible values are:
@@ -240,7 +212,7 @@ for more details.
240212Defines a custom command and its arguments to run when opening downloads instead of the default.
241213(For example,
242214.Sy ["my-open",\ "--file"] . )
243.Sy proxy
215.It Sy proxy
244216When this subsection is present, you can configure how requests are proxied to the homeserver.
245217See
246218.Sx PROXYING
@@ -353,6 +325,57 @@ and
353325Both can be used via
354326.Dq Sy title|prompt .
355327.El
328.Sh IMAGE PREVIEWS
329The
330.Sy settings.image_preview
331subsection allows configuring image previews.
332.Pp
333The available fields in this subsection are:
334.Bl -tag -width Ds
335.It Sy enabled
336Defaults to
337.Sy true .
338.It Sy lazy_load
339If
340.Sy true
341(the default), download and render image previews when viewing a message with an image.
342If
343.Sy false ,
344load previews as soon as a message with an image is received.
345.It Sy size
346An optional object with
347.Sy width
348and
349.Sy height
350fields to specify the preview size in cells.
351Defaults to 66 and 10.
352.It Sy protocol
353An optional object to override settings that will normally be guessed automatically:
354.Bl -tag -width Ds
355.It Sy type
356An optional string set to one of the protocol types:
357.Dq Sy sixel ,
358.Dq Sy kitty ,
359.Dq Sy iterm2 ,
360and
361.Dq Sy halfblocks .
362.It Sy font_size
363An optional list of two numbers representing font width and height in pixels.
364.It Sy filter
365The sample filter used to scale images.
366Possible values are:
367.Dq Sy Nearest ,
368.Dq Sy Triangle
369(default) ,
370.Dq Sy CatmullRom ,
371.Dq Sy Gaussian ,
372and
373.Dq Sy Lanczos3 .
374See
375.Lk https://docs.rs/image/0.25.10/image/imageops/enum.FilterType.html
376for more information.
377.El
378.El
356379.Sh MOUSE
357380The
358381.Sy settings.mouse
src/base.rs +14 −72
@@ -19,7 +19,6 @@ use ratatui::{
1919 text::{Line, Span},
2020 widgets::{Paragraph, Widget},
2121};
22use ratatui_image::picker::{Picker, ProtocolType};
2322use serde::{
2423 Deserialize,
2524 Deserializer,
@@ -98,10 +97,9 @@ use modalkit::{
9897 prelude::{CommandType, MoveDir1D, WordStyle},
9998};
10099
101use crate::config::ImagePreviewSize;
102100use crate::preview::PreviewKind;
103101use crate::{
104 config::{ApplicationSettings, ImagePreviewProtocolValues},
102 config::ApplicationSettings,
105103 message::{Message, MessageEvent, MessageKey, MessageTimeStamp, Messages},
106104 notifications::NotificationHandle,
107105 preview::PreviewManager,
@@ -1340,16 +1338,10 @@ impl RoomInfo {
13401338 content: StickerEventContent { source, .. },
13411339 ..
13421340 }) = &sticker &&
1343 let Some(image_preview) = &settings.tunables.image_preview
1341 settings.tunables.image_preview.enabled
13441342 {
13451343 let source = source.clone().into();
1346 previews.register_preview(
1347 settings,
1348 &source,
1349 PreviewKind::Message,
1350 image_preview.size,
1351 worker,
1352 );
1344 previews.register_preview(settings, &source, PreviewKind::Message, worker);
13531345 }
13541346
13551347 let loc = EventLocation::Message(thread_root.clone(), key.clone());
@@ -1371,18 +1363,19 @@ impl RoomInfo {
13711363 return;
13721364 };
13731365 let image_uri = OwnedMxcUri::from(orig_react.content.relates_to.key.as_str());
1374 let source = if image_uri.is_valid() && settings.tunables.image_preview.is_some() {
1366 let source = if image_uri.is_valid() && settings.tunables.image_preview.enabled {
13751367 Some(MediaSource::Plain(image_uri))
13761368 } else {
13771369 None
13781370 };
13791371
1380 self.insert_reaction(react, source.clone());
1381
1382 if let (Some(source), Some(_)) = (source, &settings.tunables.image_preview) {
1383 let size = ImagePreviewSize { width: 2, height: 1 };
1384 previews.register_preview(settings, &source, PreviewKind::Reaction, size, worker);
1372 if settings.tunables.image_preview.enabled &&
1373 let Some(source) = source.as_ref()
1374 {
1375 previews.register_preview(settings, source, PreviewKind::Reaction, worker);
13851376 }
1377
1378 self.insert_reaction(react, source);
13861379 }
13871380
13881381 /// Insert an edit.
@@ -1530,15 +1523,9 @@ impl RoomInfo {
15301523 content: RoomMessageEventContent { msgtype: MessageType::Image(c), .. },
15311524 ..
15321525 }) = &ev &&
1533 let Some(image_preview) = &settings.tunables.image_preview
1526 settings.tunables.image_preview.enabled
15341527 {
1535 previews.register_preview(
1536 settings,
1537 &c.source,
1538 PreviewKind::Message,
1539 image_preview.size,
1540 worker,
1541 )
1528 previews.register_preview(settings, &c.source, PreviewKind::Message, worker)
15421529 }
15431530
15441531 self.insert(ev);
@@ -1733,51 +1720,6 @@ fn emoji_map() -> CompletionMap<String, &'static Emoji> {
17331720 return emojis;
17341721}
17351722
1736#[cfg(unix)]
1737fn picker_from_termios(protocol_type: Option<ProtocolType>) -> Option<Picker> {
1738 let mut picker = match Picker::from_query_stdio() {
1739 Ok(picker) => picker,
1740 Err(e) => {
1741 tracing::error!("Failed to setup image previews: {e}");
1742 return None;
1743 },
1744 };
1745
1746 if let Some(protocol_type) = protocol_type {
1747 picker.set_protocol_type(protocol_type);
1748 }
1749
1750 Some(picker)
1751}
1752
1753/// Windows cannot guess the right protocol, and always needs type and font_size.
1754#[cfg(windows)]
1755fn picker_from_termios(_: Option<ProtocolType>) -> Option<Picker> {
1756 tracing::error!(
1757 "\"image_preview\" requires \"protocol\" with \"type\" and \"font_size\" options on Windows."
1758 );
1759 None
1760}
1761
1762fn picker_from_settings(settings: &ApplicationSettings) -> Option<Picker> {
1763 let image_preview = settings.tunables.image_preview.as_ref()?;
1764 let image_preview_protocol = image_preview.protocol.as_ref();
1765
1766 if let Some(&ImagePreviewProtocolValues {
1767 r#type: Some(protocol_type),
1768 font_size: Some(font_size),
1769 }) = image_preview_protocol
1770 {
1771 // User forced type and font_size: use that.
1772 let mut picker = Picker::from_fontsize(font_size);
1773 picker.set_protocol_type(protocol_type);
1774 Some(picker)
1775 } else {
1776 // Guess, but use type if forced.
1777 picker_from_termios(image_preview_protocol.and_then(|p| p.r#type))
1778 }
1779}
1780
17811723/// Information gathered during server syncs about joined rooms.
17821724#[derive(Default)]
17831725pub struct SyncInfo {
@@ -1922,12 +1864,12 @@ pub struct ChatStore {
19221864impl ChatStore {
19231865 /// Create a new [ChatStore].
19241866 pub fn new(worker: Requester, settings: ApplicationSettings) -> Self {
1925 let picker = picker_from_settings(&settings);
1867 let previews = PreviewManager::new(&settings);
19261868
19271869 ChatStore {
19281870 worker,
19291871 settings,
1930 previews: PreviewManager::new(picker),
1872 previews,
19311873 cmds: crate::commands::setup_commands(),
19321874 emojis: emoji_map(),
19331875
src/config.rs +11 −6
@@ -19,6 +19,7 @@ use matrix_sdk::reqwest::header::{HeaderMap, HeaderValue};
1919use matrix_sdk::ruma::{OwnedDeviceId, OwnedRoomAliasId, OwnedRoomId, OwnedUserId, UserId};
2020use ratatui::style::{Color, Modifier as StyleModifier, Style};
2121use ratatui::text::Span;
22use ratatui_image::FilterType;
2223use ratatui_image::picker::ProtocolType;
2324use serde::{Deserialize, Deserializer, Serialize, de::Error as SerdeError, de::Visitor};
2425use url::Url;
@@ -692,24 +693,27 @@ pub struct Notifications {
692693
693694#[derive(Clone)]
694695pub struct ImagePreviewValues {
696 pub enabled: bool,
695697 pub lazy_load: bool,
696698 pub size: ImagePreviewSize,
697 pub protocol: Option<ImagePreviewProtocolValues>,
699 pub protocol: ImagePreviewProtocolValues,
698700}
699701
700702#[derive(Clone, Debug, Default, Deserialize)]
701703pub struct ImagePreview {
704 pub enabled: Option<bool>,
702705 pub lazy_load: Option<bool>,
703706 pub size: Option<ImagePreviewSize>,
704707 pub protocol: Option<ImagePreviewProtocolValues>,
705708}
706709
707710impl ImagePreview {
708 fn values(self) -> ImagePreviewValues {
711 pub fn values(self) -> ImagePreviewValues {
709712 ImagePreviewValues {
713 enabled: self.enabled.unwrap_or(true),
710714 lazy_load: self.lazy_load.unwrap_or(true),
711715 size: self.size.unwrap_or_default(),
712 protocol: self.protocol,
716 protocol: self.protocol.unwrap_or_default(),
713717 }
714718 }
715719}
@@ -726,9 +730,10 @@ impl Default for ImagePreviewSize {
726730 }
727731}
728732
729#[derive(Clone, Debug, Deserialize)]
733#[derive(Clone, Debug, Deserialize, Default)]
730734pub struct ImagePreviewProtocolValues {
731735 pub r#type: Option<ProtocolType>,
736 pub filter: Option<FilterType>,
732737 pub font_size: Option<(u16, u16)>,
733738}
734739
@@ -833,7 +838,7 @@ pub struct TunableValues {
833838 pub mouse: Mouse,
834839 pub notifications: Notifications,
835840 pub terminal: TerminalValues,
836 pub image_preview: Option<ImagePreviewValues>,
841 pub image_preview: ImagePreviewValues,
837842 pub user_gutter_width: usize,
838843 pub external_edit_file_suffix: String,
839844 pub tabstop: usize,
@@ -971,7 +976,7 @@ impl Tunables {
971976 open_command: self.open_command,
972977 mouse: self.mouse.unwrap_or_default(),
973978 notifications: self.notifications.unwrap_or_default(),
974 image_preview: self.image_preview.map(ImagePreview::values),
979 image_preview: self.image_preview.unwrap_or_default().values(),
975980 user_gutter_width: self.user_gutter_width.unwrap_or(30),
976981 external_edit_file_suffix: self
977982 .external_edit_file_suffix
src/message/printer.rs +1 −1
@@ -52,7 +52,7 @@ impl<'a> TextPrinter<'a> {
5252
5353 /// The `(x, y)` position where the next text will be printed.
5454 pub fn cursor_pos(&self) -> (usize, usize) {
55 (self.curr_width, self.text.lines.len().saturating_sub(1))
55 (self.curr_width, self.text.lines.len())
5656 }
5757
5858 /// Configure the alignment for each line.
src/preview.rs +69 −22
@@ -6,12 +6,12 @@ use matrix_sdk::{
66 ruma::events::room::MediaSource,
77};
88use ratatui::layout::Rect;
9use ratatui_image::{Resize, picker::Picker, protocol::Protocol};
9use ratatui_image::{FilterType, Resize, picker::Picker, protocol::Protocol};
1010use tokio::sync::Semaphore;
1111
1212use crate::{
1313 base::{AsyncProgramStore, IambError},
14 config::{ApplicationSettings, ImagePreviewSize},
14 config::{ApplicationSettings, ImagePreviewSize, ImagePreviewValues},
1515 worker::Requester,
1616};
1717
@@ -28,9 +28,18 @@ pub enum PreviewKind {
2828 Reaction,
2929}
3030
31impl PreviewKind {
32 fn image_size(self, image_preview: &ImagePreviewValues) -> ImagePreviewSize {
33 match self {
34 Self::Message => image_preview.size,
35 Self::Reaction => ImagePreviewSize { width: 2, height: 1 },
36 }
37 }
38}
39
3140pub struct PreviewManager {
3241 /// Image preview "protocol" picker.
33 picker: Option<Arc<Picker>>,
42 picker: Arc<Picker>,
3443
3544 /// Permits for rendering images in background thread.
3645 permits: Arc<Semaphore>,
@@ -40,9 +49,11 @@ pub struct PreviewManager {
4049}
4150
4251impl PreviewManager {
43 pub fn new(picker: Option<Picker>) -> Self {
52 pub fn new(settings: &ApplicationSettings) -> Self {
53 let picker = picker_from_settings(settings);
54
4455 Self {
45 picker: picker.map(Into::into),
56 picker: picker.into(),
4657 permits: Arc::new(Semaphore::new(2)),
4758 previews: Default::default(),
4859 }
@@ -61,7 +72,6 @@ impl PreviewManager {
6172 let Some(status) = self.previews.get_mut(&(source.unique_key(), kind)) else {
6273 return;
6374 };
64 let Some(picker) = &self.picker else { return };
6575
6676 if let ImageStatus::Queued(size) = status {
6777 let size = *size;
@@ -71,7 +81,7 @@ impl PreviewManager {
7181 source.to_owned(),
7282 kind,
7383 size.to_owned(),
74 Arc::clone(picker),
84 Arc::clone(&self.picker),
7585 Arc::clone(&self.permits),
7686 );
7787 }
@@ -82,30 +92,55 @@ impl PreviewManager {
8292 settings: &ApplicationSettings,
8393 source: &MediaSource,
8494 kind: PreviewKind,
85 size: ImagePreviewSize,
8695 worker: &Requester,
8796 ) {
88 if self.picker.is_none() {
89 return;
90 }
91
9297 let key = (source.unique_key(), kind);
9398 if self.previews.contains_key(&key) {
9499 return;
95100 }
101
102 let size = kind.image_size(&settings.tunables.image_preview);
96103 self.previews.insert(key, ImageStatus::Queued(size));
97104
98 if settings
99 .tunables
100 .image_preview
101 .as_ref()
102 .is_some_and(|setting| !setting.lazy_load)
103 {
105 if settings.tunables.image_preview.enabled && !settings.tunables.image_preview.lazy_load {
104106 self.load(source, kind, worker);
105107 }
106108 }
107109}
108110
111#[cfg(not(windows))]
112fn picker_from_query() -> Picker {
113 // XXX: documentation says to use this query on alternate screen but it seems to be fine
114 Picker::from_query_stdio().unwrap_or_else(|e| {
115 tracing::warn!("Failed to setup image previews (falling back to halfblock rendering): {e}");
116 Picker::halfblocks()
117 })
118}
119
120#[cfg(windows)]
121fn picker_from_query() -> Picker {
122 tracing::error!(
123 "\"image_preview\" requires \"protocol\" with \"type\" and \"font_size\" options on Windows."
124 );
125 Picker::halfblocks()
126}
127
128fn picker_from_settings(settings: &ApplicationSettings) -> Picker {
129 let mut picker = if let Some(font_size) = settings.tunables.image_preview.protocol.font_size {
130 #[expect(deprecated, reason = "from_query_stdio doesn't work on windows")]
131 Picker::from_fontsize(font_size)
132 } else {
133 picker_from_query()
134 };
135
136 // user forced protocol type; use that
137 if let Some(protocol_type) = settings.tunables.image_preview.protocol.r#type {
138 picker.set_protocol_type(protocol_type);
139 }
140
141 picker
142}
143
109144impl From<ImagePreviewSize> for Rect {
110145 fn from(value: ImagePreviewSize) -> Self {
111146 Rect::new(0, 0, value.width as _, value.height as _)
@@ -132,6 +167,7 @@ pub async fn load_image(
132167 picker: Arc<Picker>,
133168 permits: Arc<Semaphore>,
134169 size: ImagePreviewSize,
170 filter: FilterType,
135171 ) -> Result<ImageStatus, IambError> {
136172 let reader = media
137173 .get_media_content(&MediaRequestParameters { source, format: MediaFormat::File }, true)
@@ -141,16 +177,16 @@ pub async fn load_image(
141177 .map_err(IambError::Matrix)
142178 .and_then(|reader| reader.with_guessed_format().map_err(IambError::IOError))?;
143179
144 let image = reader.decode().map_err(IambError::Image)?;
145
146180 let permit = permits
147181 .acquire()
148182 .await
149183 .map_err(|err| IambError::Preview(err.to_string()))?;
150184
151185 let handle = tokio::task::spawn_blocking(move || {
186 let image = reader.decode().map_err(IambError::Image)?;
187
152188 picker
153 .new_protocol(image, size.into(), Resize::Fit(None))
189 .new_protocol(image, size.into(), Resize::Fit(Some(filter)))
154190 .map_err(|err| IambError::Preview(err.to_string()))
155191 });
156192
@@ -161,7 +197,18 @@ pub async fn load_image(
161197 }
162198 let key = source.unique_key();
163199
164 let status = match load_image_inner(media, source, picker, permits, size).await {
200 let filter = store
201 .lock()
202 .await
203 .application
204 .settings
205 .tunables
206 .image_preview
207 .protocol
208 .filter
209 .unwrap_or(FilterType::Triangle);
210
211 let status = match load_image_inner(media, source, picker, permits, size, filter).await {
165212 Ok(status) => status,
166213 Err(err) => ImageStatus::Error(format!("{err:?}")),
167214 };
src/tests.rs +2 −2
@@ -1,7 +1,6 @@
11use std::path::PathBuf;
22use std::{collections::HashMap, iter::FromIterator as _};
33
4use matrix_sdk::ruma::MilliSecondsSinceUnixEpoch;
54use matrix_sdk::ruma::{
65 EventId,
76 OwnedEventId,
@@ -14,6 +13,7 @@ use matrix_sdk::ruma::{
1413 server_name,
1514 user_id,
1615};
16use matrix_sdk::ruma::{MilliSecondsSinceUnixEpoch, assign};
1717
1818use lazy_static::lazy_static;
1919use ratatui::style::{Color, Style};
@@ -202,7 +202,7 @@ pub fn mock_tunables() -> TunableValues {
202202 show_message: true,
203203 sound_hint: None,
204204 },
205 image_preview: None,
205 image_preview: assign!(ImagePreview::default().values(), {enabled: false}),
206206 user_gutter_width: 30,
207207 tabstop: 4,
208208 members_split: Default::default(),
src/windows/room/scrollback.rs +25 −23
@@ -1364,34 +1364,36 @@ impl StatefulWidget for Scrollback<'_> {
13641364 let mut prev = prevmsg(&corner_key, thread);
13651365
13661366 // load image previews
1367 for (key, item) in thread.range(&corner_key..).rev() {
1368 if let Some(source) = item.image_preview() {
1369 self.store.application.previews.load(
1370 source,
1371 PreviewKind::Message,
1372 &self.store.application.worker,
1373 );
1374 }
1375 let reply = item
1376 .reply_to()
1377 .or_else(|| item.thread_root())
1378 .and_then(|e| info.get_event(&e))
1379 .and_then(|msg| msg.image_preview());
1380 if let Some(source) = reply {
1381 self.store.application.previews.load(
1382 source,
1383 PreviewKind::Message,
1384 &self.store.application.worker,
1385 );
1386 }
1387 if let Some(event_id) = key.id.as_origin() {
1388 for source in info.get_reaction_images(event_id) {
1367 if settings.tunables.image_preview.enabled {
1368 for (key, item) in thread.range(&corner_key..).rev() {
1369 if let Some(source) = item.image_preview() {
13891370 self.store.application.previews.load(
13901371 source,
1391 PreviewKind::Reaction,
1372 PreviewKind::Message,
13921373 &self.store.application.worker,
13931374 );
13941375 }
1376 let reply = item
1377 .reply_to()
1378 .or_else(|| item.thread_root())
1379 .and_then(|e| info.get_event(&e))
1380 .and_then(|msg| msg.image_preview());
1381 if let Some(source) = reply {
1382 self.store.application.previews.load(
1383 source,
1384 PreviewKind::Message,
1385 &self.store.application.worker,
1386 );
1387 }
1388 if let Some(event_id) = key.id.as_origin() {
1389 for source in info.get_reaction_images(event_id) {
1390 self.store.application.previews.load(
1391 source,
1392 PreviewKind::Reaction,
1393 &self.store.application.worker,
1394 );
1395 }
1396 }
13951397 }
13961398 }
13971399