Add a flag on new notifications
This commit is contained in:
parent
fbc46e0517
commit
cdbc545d5e
3 changed files with 16 additions and 6 deletions
16
app/admin.py
16
app/admin.py
|
@ -721,13 +721,9 @@ async def get_notifications(
|
|||
actors_metadata = await get_actors_metadata(
|
||||
db_session, [notif.actor for notif in notifications if notif.actor]
|
||||
)
|
||||
|
||||
for notif in notifications:
|
||||
notif.is_new = False
|
||||
await db_session.commit()
|
||||
|
||||
more_unread_count = 0
|
||||
next_cursor = None
|
||||
|
||||
if notifications and remaining_count > page_size:
|
||||
decoded_next_cursor = notifications[-1].created_at
|
||||
next_cursor = pagination.encode_cursor(decoded_next_cursor)
|
||||
|
@ -741,7 +737,8 @@ async def get_notifications(
|
|||
)
|
||||
)
|
||||
|
||||
return await templates.render_template(
|
||||
# Render the template before we change the new flag on notifications
|
||||
tpl_resp = await templates.render_template(
|
||||
db_session,
|
||||
request,
|
||||
"notifications.html",
|
||||
|
@ -753,6 +750,13 @@ async def get_notifications(
|
|||
},
|
||||
)
|
||||
|
||||
if len({notif.id for notif in notifications if notif.is_new}):
|
||||
for notif in notifications:
|
||||
notif.is_new = False
|
||||
await db_session.commit()
|
||||
|
||||
return tpl_resp
|
||||
|
||||
|
||||
@router.get("/object")
|
||||
async def admin_object(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue