Make the info panel show the correct last alerting
Before, it was checking against the moved pointer, which could cause inaccurate
This commit is contained in:
@@ -10,6 +10,7 @@ class UpdateTrigger:
|
||||
def __init__(self, alert: Alert):
|
||||
self._alert : Alert = alert
|
||||
self._last_trigger : Tuple[datetime.datetime, int] | None = None
|
||||
self._last_alerting: Tuple[datetime.datetime, int] | None = None
|
||||
self._squelched : bool = False
|
||||
|
||||
@property
|
||||
@@ -20,6 +21,9 @@ class UpdateTrigger:
|
||||
def last_trigger(self) -> Tuple[datetime.datetime, int] | None:
|
||||
return self._last_trigger
|
||||
|
||||
def last_alerting(self) -> Tuple[datetime.datetime, int] | None:
|
||||
return self._last_alerting
|
||||
|
||||
def _find_next_trigger(self, comparison_operator: operator, starting_point: datetime.datetime, history: List[Tuple[datetime.datetime, int]]):
|
||||
candidate_datum : Tuple[datetime.datetime, int] | None = None
|
||||
for datum in history:
|
||||
@@ -78,6 +82,7 @@ class UpdateTrigger:
|
||||
if new_datum[0] > now - time_range:
|
||||
if self._last_trigger is None:
|
||||
self._last_trigger = new_datum
|
||||
self._last_alerting = new_datum
|
||||
return True
|
||||
|
||||
# If the self._last_trigger falls out of scope of the alert, find the next thing that would have triggered
|
||||
@@ -88,6 +93,7 @@ class UpdateTrigger:
|
||||
|
||||
if comparison_operator(new_datum[1], self._last_trigger[1]):
|
||||
self._last_trigger = new_datum
|
||||
self._last_alerting = new_datum
|
||||
was_squelched = self._squelched
|
||||
self._squelched = True
|
||||
return not was_squelched
|
||||
|
||||
Reference in New Issue
Block a user