0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-06 22:59:22 +01:00

Only send a badge-reset if the user actually has unread notifications.

This commit is contained in:
David Baker 2015-01-29 16:10:01 +00:00
parent b0b80074e0
commit 8b1dd9f57f

View file

@ -56,6 +56,7 @@ class Pusher(object):
# The last value of last_active_time that we saw # The last value of last_active_time that we saw
self.last_last_active_time = 0 self.last_last_active_time = 0
self.has_unread = True
@defer.inlineCallbacks @defer.inlineCallbacks
def _actions_for_event(self, ev): def _actions_for_event(self, ev):
@ -180,6 +181,7 @@ class Pusher(object):
processed = True processed = True
else: else:
rejected = yield self.dispatch_push(single_event, tweaks) rejected = yield self.dispatch_push(single_event, tweaks)
self.has_unread = True
if isinstance(rejected, list) or isinstance(rejected, tuple): if isinstance(rejected, list) or isinstance(rejected, tuple):
processed = True processed = True
for pk in rejected: for pk in rejected:
@ -290,9 +292,12 @@ class Pusher(object):
if 'last_active' in state.state: if 'last_active' in state.state:
last_active = state.state['last_active'] last_active = state.state['last_active']
if last_active > self.last_last_active_time: if last_active > self.last_last_active_time:
self.last_last_active_time = last_active
if self.has_unread:
logger.info("Resetting badge count for %s", self.user_name) logger.info("Resetting badge count for %s", self.user_name)
self.reset_badge_count() self.reset_badge_count()
self.last_last_active_time = last_active self.has_unread = False
def _value_for_dotted_key(dotted_key, event): def _value_for_dotted_key(dotted_key, event):