Skip to content

Commit 99f11dd

Browse files
committed
fix(agent): retain fresh battery status without a percentage
1 parent 48c7f1f commit 99f11dd

27 files changed

Lines changed: 55 additions & 29 deletions

File tree

‎crates/openlogi-agent/src/power_source/macos.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,13 @@ fn online_accessories(
477477
.get(&identifier)
478478
.filter(|tracked| !tracked.identity.conflicts_with(&identity))
479479
.and_then(|tracked| tracked.published.as_ref())
480-
.map(|published| (published.percentage, published.status))
480+
.map(|published| {
481+
let status = paired
482+
.battery
483+
.as_ref()
484+
.map_or(published.status, |battery| battery.status);
485+
(published.percentage, status)
486+
})
481487
});
482488
let reading = battery.map(|(percentage, status)| AccessoryPower {
483489
name: config_key

‎crates/openlogi-agent/src/power_source/macos/tests.rs‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,24 @@ fn level_only_readings_never_invent_percentage_and_preserve_last_reported_value(
608608

609609
inv.paired[0].battery.as_mut().unwrap().percentage = None;
610610
config.set_device_custom_name(key, Some("Renamed Mouse".into()));
611+
for (ix, status) in [
612+
BatteryStatus::Charging,
613+
BatteryStatus::Full,
614+
BatteryStatus::Error,
615+
]
616+
.into_iter()
617+
.enumerate()
618+
{
619+
inv.paired[0].battery.as_mut().unwrap().status = status;
620+
publisher.reconcile(&config, std::slice::from_ref(&inv), now);
621+
assert_eq!(publisher.backend.live[key].percentage, 0);
622+
assert_eq!(publisher.backend.live[key].name, "Renamed Mouse");
623+
assert_eq!(publisher.backend.live[key].status, status);
624+
assert_eq!(publisher.backend.writes, ix + 2);
625+
}
626+
inv.paired[0].battery = None;
611627
publisher.reconcile(&config, &[inv], now);
612628
assert_eq!(publisher.backend.live[key].percentage, 0);
613-
assert_eq!(publisher.backend.live[key].name, "Renamed Mouse");
614-
assert_eq!(publisher.backend.writes, 2);
629+
assert_eq!(publisher.backend.live[key].status, BatteryStatus::Error);
630+
assert_eq!(publisher.backend.writes, 4);
615631
}

‎crates/openlogi-ui/locales/be.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ starting = "Starting"
8484
waiting = "Waiting for OpenLogi agent"
8585
active_singular = "Active · %{count} device"
8686
active_plural = "Active · %{count} devices"
87-
empty = "Connect a mouse or keyboard through Bolt or Unifying. macOS shows Bluetooth devices itself."
87+
empty = "No Bolt or Unifying mouse or keyboard has reported a battery percentage yet. macOS shows Bluetooth devices itself."
8888
unavailable = "Unavailable on this version of macOS"
8989
failed_singular = "Battery updates failed · %{count} device published"
9090
failed_plural = "Battery updates failed · %{count} devices published"

‎crates/openlogi-ui/locales/cs.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ starting = "Starting"
8484
waiting = "Waiting for OpenLogi agent"
8585
active_singular = "Active · %{count} device"
8686
active_plural = "Active · %{count} devices"
87-
empty = "Connect a mouse or keyboard through Bolt or Unifying. macOS shows Bluetooth devices itself."
87+
empty = "No Bolt or Unifying mouse or keyboard has reported a battery percentage yet. macOS shows Bluetooth devices itself."
8888
unavailable = "Unavailable on this version of macOS"
8989
failed_singular = "Battery updates failed · %{count} device published"
9090
failed_plural = "Battery updates failed · %{count} devices published"

‎crates/openlogi-ui/locales/da.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ starting = "Starting"
8484
waiting = "Waiting for OpenLogi agent"
8585
active_singular = "Active · %{count} device"
8686
active_plural = "Active · %{count} devices"
87-
empty = "Connect a mouse or keyboard through Bolt or Unifying. macOS shows Bluetooth devices itself."
87+
empty = "No Bolt or Unifying mouse or keyboard has reported a battery percentage yet. macOS shows Bluetooth devices itself."
8888
unavailable = "Unavailable on this version of macOS"
8989
failed_singular = "Battery updates failed · %{count} device published"
9090
failed_plural = "Battery updates failed · %{count} devices published"

‎crates/openlogi-ui/locales/de.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ starting = "Wird gestartet"
8484
waiting = "Warte auf OpenLogi-Agent"
8585
active_singular = "Aktiv · %{count} Gerät"
8686
active_plural = "Aktiv · %{count} Geräte"
87-
empty = "Verbinde eine Maus oder Tastatur über Bolt oder Unifying. Bluetooth-Geräte zeigt macOS selbst an."
87+
empty = "Noch keine Maus oder Tastatur über Bolt oder Unifying hat einen Akkustand in Prozent gemeldet. Bluetooth-Geräte zeigt macOS selbst an."
8888
unavailable = "Auf dieser macOS-Version nicht verfügbar"
8989
failed_singular = "Akkuaktualisierung fehlgeschlagen · %{count} Gerät veröffentlicht"
9090
failed_plural = "Akkuaktualisierung fehlgeschlagen · %{count} Geräte veröffentlicht"

‎crates/openlogi-ui/locales/el.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ starting = "Starting"
8484
waiting = "Waiting for OpenLogi agent"
8585
active_singular = "Active · %{count} device"
8686
active_plural = "Active · %{count} devices"
87-
empty = "Connect a mouse or keyboard through Bolt or Unifying. macOS shows Bluetooth devices itself."
87+
empty = "No Bolt or Unifying mouse or keyboard has reported a battery percentage yet. macOS shows Bluetooth devices itself."
8888
unavailable = "Unavailable on this version of macOS"
8989
failed_singular = "Battery updates failed · %{count} device published"
9090
failed_plural = "Battery updates failed · %{count} devices published"

‎crates/openlogi-ui/locales/en.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ starting = "Starting"
8484
waiting = "Waiting for OpenLogi agent"
8585
active_singular = "Active · %{count} device"
8686
active_plural = "Active · %{count} devices"
87-
empty = "Connect a mouse or keyboard through Bolt or Unifying. macOS shows Bluetooth devices itself."
87+
empty = "No Bolt or Unifying mouse or keyboard has reported a battery percentage yet. macOS shows Bluetooth devices itself."
8888
unavailable = "Unavailable on this version of macOS"
8989
failed_singular = "Battery updates failed · %{count} device published"
9090
failed_plural = "Battery updates failed · %{count} devices published"

‎crates/openlogi-ui/locales/es.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ starting = "Starting"
8484
waiting = "Waiting for OpenLogi agent"
8585
active_singular = "Active · %{count} device"
8686
active_plural = "Active · %{count} devices"
87-
empty = "Connect a mouse or keyboard through Bolt or Unifying. macOS shows Bluetooth devices itself."
87+
empty = "No Bolt or Unifying mouse or keyboard has reported a battery percentage yet. macOS shows Bluetooth devices itself."
8888
unavailable = "Unavailable on this version of macOS"
8989
failed_singular = "Battery updates failed · %{count} device published"
9090
failed_plural = "Battery updates failed · %{count} devices published"

‎crates/openlogi-ui/locales/fi.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ starting = "Starting"
8484
waiting = "Waiting for OpenLogi agent"
8585
active_singular = "Active · %{count} device"
8686
active_plural = "Active · %{count} devices"
87-
empty = "Connect a mouse or keyboard through Bolt or Unifying. macOS shows Bluetooth devices itself."
87+
empty = "No Bolt or Unifying mouse or keyboard has reported a battery percentage yet. macOS shows Bluetooth devices itself."
8888
unavailable = "Unavailable on this version of macOS"
8989
failed_singular = "Battery updates failed · %{count} device published"
9090
failed_plural = "Battery updates failed · %{count} devices published"

0 commit comments

Comments
 (0)