up-device: Remove history only on device id change

Remove the history when the device id was changed.
This commit is contained in:
Kate Hsuan 2024-02-26 17:25:47 +08:00
parent 76e2b9e571
commit bbb593d306

View file

@ -230,12 +230,16 @@ up_device_notify (GObject *object, GParamSpec *pspec)
if (g_strcmp0 (pspec->name, "type") == 0 ||
g_strcmp0 (pspec->name, "is-present") == 0) {
update_icon_name (device);
/* Clearing the history object will force lazily loading. */
g_clear_object (&priv->history);
/* Clearing the history object for lazily loading when device id was changed. */
if (priv->history != NULL &&
!up_history_is_device_id_equal (priv->history, up_device_get_id(device)))
g_clear_object (&priv->history);
} else if (g_strcmp0 (pspec->name, "vendor") == 0 ||
g_strcmp0 (pspec->name, "model") == 0 ||
g_strcmp0 (pspec->name, "serial") == 0) {
g_clear_object (&priv->history);
if (priv->history != NULL &&
!up_history_is_device_id_equal (priv->history, up_device_get_id(device)))
g_clear_object (&priv->history);
} else if (g_strcmp0 (pspec->name, "power-supply") == 0 ||
g_strcmp0 (pspec->name, "time-to-empty") == 0) {
update_warning_level (device);