mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-18 22:26:34 +00:00
Merge pull request #1328 from bookwyrm-social/unread-count
Increment unread count less wildly
This commit is contained in:
commit
ac3a989e37
1 changed files with 6 additions and 5 deletions
|
@ -23,11 +23,12 @@ class ActivityStream(RedisStore):
|
||||||
"""statuses are sorted by date published"""
|
"""statuses are sorted by date published"""
|
||||||
return obj.published_date.timestamp()
|
return obj.published_date.timestamp()
|
||||||
|
|
||||||
def add_status(self, status):
|
def add_status(self, status, increment_unread=False):
|
||||||
"""add a status to users' feeds"""
|
"""add a status to users' feeds"""
|
||||||
# the pipeline contains all the add-to-stream activities
|
# the pipeline contains all the add-to-stream activities
|
||||||
pipeline = self.add_object_to_related_stores(status, execute=False)
|
pipeline = self.add_object_to_related_stores(status, execute=False)
|
||||||
|
|
||||||
|
if increment_unread:
|
||||||
for user in self.get_audience(status):
|
for user in self.get_audience(status):
|
||||||
# add to the unread status count
|
# add to the unread status count
|
||||||
pipeline.incr(self.unread_id(user))
|
pipeline.incr(self.unread_id(user))
|
||||||
|
@ -262,7 +263,7 @@ def add_status_on_create(sender, instance, created, *args, **kwargs):
|
||||||
return
|
return
|
||||||
|
|
||||||
for stream in streams.values():
|
for stream in streams.values():
|
||||||
stream.add_status(instance)
|
stream.add_status(instance, increment_unread=created)
|
||||||
|
|
||||||
if sender != models.Boost:
|
if sender != models.Boost:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue