From 2a1ae8bf6ce9d855f3ef47b94de120a2b6e6d536 Mon Sep 17 00:00:00 2001 From: Jpadilla1 Date: Tue, 29 Apr 2014 22:59:50 -0400 Subject: [PATCH] fix js jumping message --- apps/chats/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/chats/views.py b/apps/chats/views.py index 86071eb..09c8fbb 100644 --- a/apps/chats/views.py +++ b/apps/chats/views.py @@ -57,7 +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']) - if context['room_messages'].count() == 0: + if context['room_messages'].count() > 0: context['room_message_last'] = context['room_messages'].last().id-1 users = User.objects.filter( last_login__gt=self.request.user.last_logged_out, @@ -92,7 +92,7 @@ def get_ajax(self, request, *args, **kwargs): is_active__exact=1, ).order_by( '-last_login').values('username'))) } - if messages.count() == 0: + if messages.count() > 0: data['last_message_id'] = messages.last().id - 1 return self.render_json_response(data)