diff --git a/src/Services/Helpers/Image.vala b/src/Services/Helpers/Image.vala index 3db81f1b5..f3e501a2f 100644 --- a/src/Services/Helpers/Image.vala +++ b/src/Services/Helpers/Image.vala @@ -85,4 +85,12 @@ public class Tuba.Helper.Image { cb (result); }); } + + public static Gdk.Paintable? lookup_cache (string uri) { + try { + return Gdk.Texture.from_filename (GLib.Path.build_path (GLib.Path.DIR_SEPARATOR_S, cache.cache_dir, GLib.str_hash (uri).to_string ())); + } catch { + return null; + } + } } diff --git a/src/Widgets/Emoji.vala b/src/Widgets/Emoji.vala index c8f89f544..14d43465e 100644 --- a/src/Widgets/Emoji.vala +++ b/src/Widgets/Emoji.vala @@ -24,10 +24,11 @@ public class Tuba.Widgets.Emoji : Adw.Bin { shortcode = t_shortcode; } - GLib.Idle.add (() => { + var cached_paintable = Tuba.Helper.Image.lookup_cache (emoji_url); + if (cached_paintable == null) Tuba.Helper.Image.request_paintable (emoji_url, null, on_cache_response); - return GLib.Source.REMOVE; - }); + else + on_cache_response (cached_paintable); } void on_cache_response (Gdk.Paintable? data) {