Show unread status reload link
This commit is contained in:
parent
28651bd804
commit
b8cd1d5bce
7 changed files with 34 additions and 21 deletions
|
@ -1,20 +1,24 @@
|
|||
""" endpoints for getting updates about activity """
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import JsonResponse
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
|
||||
# pylint: disable= no-self-use
|
||||
@method_decorator(login_required, name="dispatch")
|
||||
class Updates(View):
|
||||
""" so the app can poll """
|
||||
from bookwyrm import activitystreams
|
||||
|
||||
def get(self, request):
|
||||
""" any notifications waiting? """
|
||||
return JsonResponse(
|
||||
{
|
||||
"notifications": request.user.notification_set.filter(
|
||||
read=False
|
||||
).count(),
|
||||
}
|
||||
)
|
||||
@login_required
|
||||
def get_notification_count(request):
|
||||
""" any notifications waiting? """
|
||||
return JsonResponse({
|
||||
"count": request.user.notification_set.filter(
|
||||
read=False
|
||||
).count(),
|
||||
})
|
||||
|
||||
@login_required
|
||||
def get_unread_status_count(request, stream):
|
||||
""" any unread statuses for this feed? """
|
||||
stream = activitystreams.streams.get(stream)
|
||||
if not stream:
|
||||
return JsonResponse({})
|
||||
return JsonResponse({
|
||||
"count": stream.get_unread_count(request.user)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue