From d8de1641a8cb00760ad395e0e63aca7909eba58c Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Fri, 27 Dec 2024 15:09:35 +0900 Subject: [PATCH 1/2] SystemUpdate: Get last refresh time via DBus --- src/DBus/SystemUpdate.vala | 1 + src/Views/OperatingSystemView.vala | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/DBus/SystemUpdate.vala b/src/DBus/SystemUpdate.vala index 5e9a16ca..637b7535 100644 --- a/src/DBus/SystemUpdate.vala +++ b/src/DBus/SystemUpdate.vala @@ -27,4 +27,5 @@ public interface SystemUpdate : Object { public abstract async void cancel () throws DBusError, IOError; public abstract async void check_for_updates (bool force, bool notify) throws DBusError, IOError; public abstract async void update () throws DBusError, IOError; + public async int64 get_last_refresh_time () throws DBusError, IOError; } diff --git a/src/Views/OperatingSystemView.vala b/src/Views/OperatingSystemView.vala index f675362b..8dde9a34 100644 --- a/src/Views/OperatingSystemView.vala +++ b/src/Views/OperatingSystemView.vala @@ -19,8 +19,6 @@ */ public class About.OperatingSystemView : Gtk.Box { - private static Settings update_settings = new Settings ("io.elementary.settings-daemon.system-update"); - private static string _bug_url; private static string bug_url { get { @@ -511,7 +509,7 @@ public class About.OperatingSystemView : Gtk.Box { updates_title.label = _("Up To Date"); updates_description.label = _("Last checked %s").printf ( Granite.DateTime.get_relative_datetime ( - new DateTime.from_unix_utc (update_settings.get_int64 ("last-refresh-time")) + new DateTime.from_unix_utc (yield update_proxy.get_last_refresh_time ()) ) ); button_stack.visible_child_name = "refresh"; From 13d420183563e6e4a75c0f2c0b27ce56004fce6c Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Fri, 27 Dec 2024 16:32:29 +0900 Subject: [PATCH 2/2] Fix build error and warning --- src/DBus/SystemUpdate.vala | 2 +- src/Views/OperatingSystemView.vala | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/DBus/SystemUpdate.vala b/src/DBus/SystemUpdate.vala index 637b7535..be284743 100644 --- a/src/DBus/SystemUpdate.vala +++ b/src/DBus/SystemUpdate.vala @@ -27,5 +27,5 @@ public interface SystemUpdate : Object { public abstract async void cancel () throws DBusError, IOError; public abstract async void check_for_updates (bool force, bool notify) throws DBusError, IOError; public abstract async void update () throws DBusError, IOError; - public async int64 get_last_refresh_time () throws DBusError, IOError; + public abstract async int64 get_last_refresh_time () throws DBusError, IOError; } diff --git a/src/Views/OperatingSystemView.vala b/src/Views/OperatingSystemView.vala index 8dde9a34..e51c1a99 100644 --- a/src/Views/OperatingSystemView.vala +++ b/src/Views/OperatingSystemView.vala @@ -507,11 +507,19 @@ public class About.OperatingSystemView : Gtk.Box { case UP_TO_DATE: updates_image.icon_name = "process-completed"; updates_title.label = _("Up To Date"); - updates_description.label = _("Last checked %s").printf ( - Granite.DateTime.get_relative_datetime ( - new DateTime.from_unix_utc (yield update_proxy.get_last_refresh_time ()) - ) - ); + + try { + var last_refresh_time = yield update_proxy.get_last_refresh_time (); + updates_description.label = _("Last checked %s").printf ( + Granite.DateTime.get_relative_datetime ( + new DateTime.from_unix_utc (last_refresh_time) + ) + ); + } catch (Error e) { + critical ("Failed to get last refresh time from Updates Backend: %s", e.message); + updates_description.label = _("Last checked unknown"); + } + button_stack.visible_child_name = "refresh"; break; case CHECKING: