@@ -3,8 +3,6 @@ use std::io::Read;
33use adw:: prelude:: * ;
44use adw:: subclass:: prelude:: * ;
55use chrono:: NaiveDateTime ;
6- use gdk_pixbuf:: Pixbuf ;
7- use gtk:: gdk_pixbuf;
86use gtk:: { gdk, gio, glib} ;
97use ntfy_daemon:: models;
108use tracing:: error;
@@ -165,9 +163,11 @@ impl MessageRow {
165163 fn build_image ( & self , url : String ) -> gtk:: Picture {
166164 let ( s, r) = async_channel:: unbounded ( ) ;
167165 gio:: spawn_blocking ( move || {
168- if let Err ( e) = Self :: fetch_image_bytes ( & url)
169- . map ( |bytes| s. send_blocking ( glib:: Bytes :: from_owned ( bytes) ) )
170- {
166+ if let Err ( e) = Self :: fetch_image_bytes ( & url) . and_then ( |bytes| {
167+ let t = gdk:: Texture :: from_bytes ( & glib:: Bytes :: from_owned ( bytes) ) ?;
168+ s. send_blocking ( t) ?;
169+ Ok ( ( ) )
170+ } ) {
171171 error ! ( error = %e)
172172 }
173173 glib:: ControlFlow :: Break
@@ -178,10 +178,8 @@ impl MessageRow {
178178 let picturec = picture. clone ( ) ;
179179
180180 self . spawn_with_near_toast ( async move {
181- let b = r. recv ( ) . await ?;
182- let stream = gio:: MemoryInputStream :: from_bytes ( & b) ;
183- let pixbuf = Pixbuf :: from_stream ( & stream, gio:: Cancellable :: NONE ) ?;
184- picturec. set_paintable ( Some ( & gdk:: Texture :: for_pixbuf ( & pixbuf) ) ) ;
181+ let t = r. recv ( ) . await ?;
182+ picturec. set_paintable ( Some ( & t) ) ;
185183 Ok :: < ( ) , anyhow:: Error > ( ( ) )
186184 } ) ;
187185
0 commit comments