app/helpers/ties_helper.rb in social_stream-0.2.3 vs app/helpers/ties_helper.rb in social_stream-0.3.0

- old
+ new

@@ -1,27 +1,30 @@ module TiesHelper def tie_brief(tie) "N contacts in common" end - def tie_link(tie) - # FIXME: tie name - if tie.relation.granted - # There is granted relation, so another user must confirmate it - # We need to render ties#new with a message - link_to t("#{ tie.relation.name }.new"), - new_tie_path("tie[sender_id]" => tie.sender.id, - "tie[receiver_id]" => tie.receiver.id, - "tie[relation_name]" => tie.relation.name), - :title => t("#{ tie.relation.name }.confirm_new", - :name => tie.receiver_subject.name), - :remote => true - + # Show current ties from current user to actor, if they exist, or provide a link + # to create a new tie to actor + def ties_to(a) + if user_signed_in? + if current_subject.ties_to(a).present? + current_subject.ties_to(a).first.relation_name + else + new_tie_link(current_subject.sent_ties.build :receiver_id => Actor.normalize_id(a)) + end else - # Tie can be established at once. - render :partial => 'ties/form', - :locals => { :tie => tie } + link_to t("contact.new.link"), new_user_session_path end + end + + def new_tie_link(tie) + link_to t("contact.new.link"), + new_tie_path("tie[sender_id]" => tie.sender.id, + "tie[receiver_id]" => tie.receiver.id), + :title => t("contact.new.title", + :name => tie.receiver_subject.name), + :remote => true end def link_follow_state link_to("Unfollow", home_path) end