Memoize the facebook invitation form on the facebook finder page
This commit is contained in:
parent
0d864935cd
commit
6d3da0d0d1
2 changed files with 14 additions and 6 deletions
|
|
@ -1,5 +1,16 @@
|
|||
module ServicesHelper
|
||||
GSUB_THIS = "FIUSDHVIUSHDVIUBAIUHAPOIUXJM"
|
||||
def contact_proxy(friend)
|
||||
friend.contact || Contact.new(:person => friend.person)
|
||||
end
|
||||
|
||||
# This method memoizes the facebook invite form in order to avoid the overhead of rendering it on every post.
|
||||
# @param [ServiceUser] friend
|
||||
# @return [String] The HTML for the form.
|
||||
def facebook_invite_form friend
|
||||
@form ||= controller.render_to_string(
|
||||
:partial => 'services/facebook_invite',
|
||||
:locals => {:uid => GSUB_THIS})
|
||||
@form.gsub(GSUB_THIS, friend.uid).html_safe
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,13 +5,10 @@
|
|||
- elsif friend.on_diaspora?
|
||||
= render 'aspect_memberships/aspect_dropdown', :contact => contact_proxy(friend), :person => friend.person, :hang => 'left'
|
||||
- else
|
||||
= form_tag service_inviter_path(:provider => 'facebook') do
|
||||
= select_tag(:aspect_id, options_from_collection_for_select(all_aspects, 'id', 'name'))
|
||||
= hidden_field_tag :uid, friend.uid
|
||||
= submit_tag t('.invite')
|
||||
= facebook_invite_form(friend)
|
||||
|
||||
- if friend.on_diaspora?
|
||||
= person_image_link(friend.person)
|
||||
= person_image_link(friend.person, :size => :thumb_small)
|
||||
- else
|
||||
= image_tag(friend.photo_url, :class => 'avatar')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue