add unread count to topnav and update subscription on thread view

This commit is contained in:
2026-05-20 14:07:15 +03:00
parent a5a3565496
commit daed16f099
3 changed files with 26 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
from flask import Blueprint, redirect, url_for, render_template, request, abort
from functools import wraps
from ..auth import login_required, get_active_user
from ..auth import login_required, get_active_user, is_logged_in
from ..models import Threads, Posts, Topics, Users, Reactions, Subscriptions
from ..util import get_form_checkbox, time_now
import math
@@ -59,6 +59,11 @@ def thread(thread_id, slug):
abort(404)
posts = thread.get_posts(PER_PAGE, page)
last_post = posts[-1]
user = get_active_user()
if user:
subscription = Subscriptions.find({'user_id': user.id, 'thread_id': thread.id})
if subscription:
subscription.update({'last_seen': last_post['created_at']})
return render_template(
'threads/thread.html', thread=thread,
posts=posts, page=page,