Replaced direct notification timer cache access with a public method.
CD / Build (push) Successful in 9s
CI / Formatting (push) Failing after 5s
CI / Linting (push) Successful in 6s
CI / Type Checking (push) Successful in 9s
CI / Spelling (push) Successful in 5s

This commit is contained in:
2026-03-11 15:49:51 -04:00
parent b8447e190c
commit a70fe972c4
2 changed files with 9 additions and 3 deletions
+8
View File
@@ -179,6 +179,14 @@ class NotificationService:
return body_text
def get_last_notification_time(self, domain: str) -> float:
"""Get the timestamp of the last notification sent for a domain.
:param domain: The stream domain.
:return: Unix timestamp of last notification, or 0 if never notified.
"""
return self.notification_timers_cache.get(domain, 0)
def _can_notify(self, domain: str) -> bool:
"""Check if enough time has passed to send another notification.
+1 -3
View File
@@ -163,8 +163,6 @@ class StreamMonitor:
# Initialize timer cache entries to prevent KeyError on first access
if domain not in self.offline_timer_cache:
self.offline_timer_cache[domain] = 0
if domain not in self.notification_service.notification_timers_cache:
self.notification_service.notification_timers_cache[domain] = 0
# Does the last known stream state lack connect/disconnect?
if (
@@ -257,7 +255,7 @@ class StreamMonitor:
# instead of a title change to avoid confusion.
if (
self.offline_timer_cache[domain]
> self.notification_service.notification_timers_cache[domain]
> self.notification_service.get_last_notification_time(domain)
):
await self.notification_service.notify_stream_live(
domain,