Fix the build for socketing of comments.haml

This commit is contained in:
Raphael Sofaer 2011-07-29 11:50:34 -07:00
parent e17fe1848f
commit 6946d28243
3 changed files with 16 additions and 2 deletions

View file

@ -17,7 +17,7 @@ class SocketsController < ApplicationController
#this should be the actual params of the controller
@params = {:user_or_id => user_or_id, :object => object}.merge(opts)
return unless Diaspora::WebSocket.is_connected?(user_id)
@_request = ActionDispatch::Request.new({})
@_request = SocketRequest.new({})
Diaspora::WebSocket.queue_to_user(user_id, action_hash(user, object, opts))
end
@ -44,4 +44,10 @@ class SocketsController < ApplicationController
def all_aspects
@all_aspects ||= user.aspects
end
class SocketRequest < ActionDispatch::Request
def format
'socket'
end
end
end

View file

@ -22,4 +22,12 @@ module CommentsHelper
:partial => 'comments/new_comment', :locals => {:post_id => GSUB_THIS, :current_user => current_user})
@form.gsub(GSUB_THIS, post_id.to_s).html_safe
end
def comment_form_wrapper_class(post)
if post.comments.empty? && request && request.format != 'mobile'
'hidden'
else
nil
end
end
end

View file

@ -14,5 +14,5 @@
= render :partial => 'comments/comment', :collection => post.comments, :locals => {:post => post}
- unless @commenting_disabled
.new_comment_form_wrapper{:class => ('hidden' if(post.comments.empty? && request.format !='mobile'))}
.new_comment_form_wrapper{:class => comment_form_wrapper_class(post)}
= new_comment_form(post.id, current_user)