From 64208ce16107720b5a2e5256c437823233dc3b06 Mon Sep 17 00:00:00 2001 From: technosf <535060+technosf@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:08:36 -0700 Subject: [PATCH] Update HeaderBar.vala Refresh cached favicon, otherwise use the cahced ico --- src/Widgets/HeaderBar.vala | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Widgets/HeaderBar.vala b/src/Widgets/HeaderBar.vala index 32341e3..140e4ba 100644 --- a/src/Widgets/HeaderBar.vala +++ b/src/Widgets/HeaderBar.vala @@ -263,13 +263,26 @@ public class Tuner.HeaderBar : Gtk.HeaderBar { * * This method asynchronously loads the favicon anew for * the given station and updates the favicon image. + * If the favicon is not available, it will load cached + * favicon or use the default icon. * * @param station The station whose favicon should be loaded. */ private void load_favicon(Model.Station station) { this.favicon.clear (); + Favicon.load_async.begin (station, true, (favicon, res) => { + var pxbuf = Favicon.load_async.end (res); + if (pxbuf != null) { + this.favicon.set_from_pixbuf (pxbuf); + this.favicon.set_size_request (48, 48); + return; + } + }); + + // If favicon is not available, use cached favicon or default icon + Favicon.load_async.begin (station, false, (favicon, res) => { var pxbuf = Favicon.load_async.end (res); if (pxbuf != null) { this.favicon.set_from_pixbuf (pxbuf); @@ -280,4 +293,4 @@ public class Tuner.HeaderBar : Gtk.HeaderBar { this.favicon.set_size_request (48, 48); }); } -} \ No newline at end of file +}