feat(src/services): rename BatteryService to Battery and add availability properties

Rename service to Battery, expose availability, charging, discharging properties and simplify interface for clarity
This commit is contained in:
sankalp committed 2026-06-17 01:45:24 +05:45
1 parent 400b8db954
commit b8d3e74afd
4 files changed
+509 -228

No files matched your search

+17 -10
View File
@@ -271,17 +271,24 @@ class CachedNotifications(Notifications):
max_cache_id = 0
for notification in data:
cached_notification = CachedNotification.create_from_dict(notification)
cache_id = cached_notification.cache_id
max_cache_id = max(max_cache_id, cache_id)
try:
cached_notification = CachedNotification.create_from_dict(notification)
cache_id = cached_notification.cache_id
max_cache_id = max(max_cache_id, cache_id)
handler_id = cached_notification.connect(
"removed-from-cache",
lambda *args: self.remove_cached_notification(notification_id=cache_id),
)
self._signal_handlers[cache_id] = handler_id
self._cached_notifications[cache_id] = cached_notification
self._count += 1
handler_id = cached_notification.connect(
"removed-from-cache",
lambda *args: self.remove_cached_notification(
notification_id=cache_id
),
)
self._signal_handlers[cache_id] = handler_id
self._cached_notifications[cache_id] = cached_notification
self._count += 1
except Exception as e:
logger.warning(
f"Failed to load a cached notification (might be from an old schema): {e}"
)
# Set next cache ID to be higher than any existing ID
self._next_cache_id = max_cache_id + 1