diff --git a/apps/chats/views.py b/apps/chats/views.py index 61ac6cb..2d13b4e 100644 --- a/apps/chats/views.py +++ b/apps/chats/views.py @@ -57,6 +57,7 @@ def get_context_data(self, **kwargs): context['form'] = self.get_form(self.get_form_class()) context['room'] = get_object_or_404(ChatRoom, slug=self.kwargs['slug']) context['room_messages'] = Message.objects.filter(room=context['room']) + context['room_message_last'] = context['room_messages'].last().id - 1 users = User.objects.filter( last_login__gt=self.request.user.last_logged_out, is_active__exact=1, ).order_by('-last_login') @@ -84,6 +85,7 @@ def get_ajax(self, request, *args, **kwargs): m.append(i['fields']) data = { 'messages': json.dumps(m), + 'last_message_id': messages.last().id - 1, 'online_users': json.dumps(list(ChatRoom.objects.get( slug=kwargs['slug']).members.filter( last_login__gt=self.request.user.last_logged_out, diff --git a/templates/chats/room.html b/templates/chats/room.html index c0e7bdb..6945a5f 100644 --- a/templates/chats/room.html +++ b/templates/chats/room.html @@ -23,7 +23,7 @@