Browse Source

Fix comments_since_last_visit on first visit

On a user's first visit to a topic, this attribute wasn't being set.
merge-requests/82/merge
Deimos 5 years ago
parent
commit
07f491a760
  1. 2
      tildes/tildes/models/topic/topic_query.py
  2. 2
      tildes/tildes/templates/topic.jinja2

2
tildes/tildes/models/topic/topic_query.py

@ -109,6 +109,8 @@ class TopicQuery(PaginatedQuery):
topic.bookmark_created_time = result.created_time topic.bookmark_created_time = result.created_time
topic.last_visit_time = result.visit_time topic.last_visit_time = result.visit_time
topic.comments_since_last_visit = None
if result.num_comments is not None: if result.num_comments is not None:
new_comments = topic.num_comments - result.num_comments new_comments = topic.num_comments - result.num_comments
# prevent showing negative "new comments" due to deletions # prevent showing negative "new comments" due to deletions

2
tildes/tildes/templates/topic.jinja2

@ -177,7 +177,7 @@
{% if request.user {% if request.user
and request.user.track_comment_visits and request.user.track_comment_visits
and not request.user.collapse_old_comments and not request.user.collapse_old_comments
and topic.comments_since_last_visit > 0 %}
and topic.comments_since_last_visit %}
<button class="btn btn-sm btn-light" data-js-comment-collapse-read-button>Collapse read</button> <button class="btn btn-sm btn-light" data-js-comment-collapse-read-button>Collapse read</button>
{% endif %} {% endif %}

Loading…
Cancel
Save