Browse Source

Sort previous notifications when marking all read

Because of the way the topic_visits update works (only updating visits
that were before the comment was posted), this will only behave
correctly when the previous notifications are processed in the order
their comments were posted.

This process needs to be replaced soon anyway, but this should make it
work correctly for now.
merge-requests/25/head
Deimos 6 years ago
parent
commit
a5664b8589
  1. 5
      tildes/tildes/views/api/web/comment.py

5
tildes/tildes/views/api/web/comment.py

@ -348,6 +348,11 @@ def put_mark_comments_read(
.all() .all()
) )
# sort the notifications by created_time of their comment so that the
# INSERT ... ON CONFLICT DO UPDATE statements work as expected
prev_notifications = sorted(
prev_notifications, key=lambda c: c.comment.created_time)
for comment_notification in prev_notifications: for comment_notification in prev_notifications:
comment_notification.is_unread = False comment_notification.is_unread = False
_increment_topic_comments_seen( _increment_topic_comments_seen(

Loading…
Cancel
Save