Skip to content

Commit

Permalink
Don't always notify
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Jan 22, 2024
1 parent d53ed05 commit eab902d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/Backends/SystemUpdate.vala
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ public class SettingsDaemon.Backends.SystemUpdate : Object {

cancellable = new GLib.Cancellable ();

check_for_updates.begin ();
check_for_updates.begin (false, true);

Timeout.add_seconds ((uint) settings.get_int64 ("refresh-interval"), () => {
check_for_updates.begin ();
check_for_updates.begin (false, true);
return Source.CONTINUE;
});
}

public async void check_for_updates (bool force = false) throws DBusError, IOError {
public async void check_for_updates (bool force, bool notify) throws DBusError, IOError {
if (current_state.state != UP_TO_DATE && current_state.state != AVAILABLE && !force) {
return;
}
Expand Down Expand Up @@ -96,12 +96,14 @@ public class SettingsDaemon.Backends.SystemUpdate : Object {
0 //FIXME: Is there a way to get update size from PackageKit
};

var notification = new Notification (_("Update Available"));
notification.set_body (_("A system update is available"));
notification.set_icon (new ThemedIcon ("software-update-available"));
notification.set_default_action (Application.ACTION_PREFIX + Application.SHOW_UPDATES_ACTION);
if (notify) {
var notification = new Notification (_("Update Available"));
notification.set_body (_("A system update is available"));
notification.set_icon (new ThemedIcon ("software-update-available"));
notification.set_default_action (Application.ACTION_PREFIX + Application.SHOW_UPDATES_ACTION);

GLib.Application.get_default ().send_notification (null, notification);
GLib.Application.get_default ().send_notification (null, notification);
}

update_state (AVAILABLE);
} catch (Error e) {
Expand Down Expand Up @@ -134,7 +136,7 @@ public class SettingsDaemon.Backends.SystemUpdate : Object {
update_state (RESTART_REQUIRED);
} catch (IOError.CANCELLED e) {
debug ("Updates were cancelled");
check_for_updates.begin (true);
check_for_updates.begin (true, false);
} catch (Error e) {
critical ("Failed to download available updates: %s", e.message);

Expand Down

0 comments on commit eab902d

Please sign in to comment.