Permalink
Browse files

Small tweak in the poll version to not render anything if there is no…

… messages to render
  • Loading branch information...
1 parent 98153ed commit 4e4c607e8e48410a964b0c5a643a2558b0c19159 @akitaonrails committed Feb 15, 2011
Showing with 5 additions and 3 deletions.
  1. +5 −3 app/controllers/retrieve_controller.rb
@@ -11,10 +11,12 @@ def retrieve_messages
@last_message ||= (Time.now - 30.seconds)
Chat.recent(@last_message).all do |messages|
list = messages.map { |msg| { "from" => msg.name, "msg" => msg.message, "sent" => msg.sent_at.to_formatted_s(:short), "timestamp" => msg.sent_at } }
- @last_message = messages.first.try(:sent_at) || @last_message
- render [list.to_json, "\n"]
+ if list.size > 0
+ @last_message = messages.first.try(:sent_at) || @last_message
+ render list.to_json
+ end
finish
end
end
-end
+end

0 comments on commit 4e4c607

Please sign in to comment.