1
0
Fork 0

fix: remove any alarm given an action

Signed-off-by: thiswillbeyourgithub <github@32mail.33mail.com>
This commit is contained in:
thiswillbeyourgithub 2023-07-07 20:03:17 +02:00 committed by Daniel Thompson
parent 1ad2ee1d66
commit 81e38a85b0

View file

@ -350,13 +350,13 @@ class Manager():
def cancel_alarm(self, time, action):
"""Unqueue an alarm."""
alarms = self._alarms
try:
if time is None:
for i, al in enumerate(self._alarms):
if self._alarms[i][1] == action:
self._alarms.remove(self._alarms[i])
if not time:
time_to_remove = [al[0] for al in alarms if al[1] == action]
[alarms.remove((t, action)) for t in time_to_remove]
else:
self._alarms.remove((time, action))
alarms.remove((time, action))
except:
return False
return True