Skip to content

Commit

Permalink
fix js jumping message
Browse files Browse the repository at this point in the history
  • Loading branch information
Jpadilla1 committed Apr 30, 2014
1 parent 8f3f864 commit 2a1ae8b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/chats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 2a1ae8b

Please sign in to comment.