This is to improve UX by making it much more obvious how to reshare a post that has already been reshared. Prior to this change, the link to reshare would show only the reshare count, e.g. "7 reshares". Most users would have no idea that they need to click "7 reshares" to reshare the post themselves.
35 lines
1.2 KiB
Ruby
35 lines
1.2 KiB
Ruby
module ResharesHelper
|
|
def reshare_error_message(reshare)
|
|
if @reshare.errors[:root_guid].present?
|
|
escape_javascript(@reshare.errors[:root_guid].first)
|
|
else
|
|
escape_javascript(t('reshares.create.failure'))
|
|
end
|
|
end
|
|
|
|
def resharable?(post)
|
|
if reshare?(post)
|
|
# Reshare post is resharable if you're not the original author nor the resharer
|
|
post.root.present? && post.root.author_id != current_user.person.id && post.author_id != current_user.person.id
|
|
else
|
|
post.author_id != current_user.person.id && post.public?
|
|
end
|
|
end
|
|
|
|
def reshare_link(post)
|
|
if reshare?(post)
|
|
return unless post.root
|
|
link_to t("reshares.reshare.reshare_original"),
|
|
reshares_path(:root_guid => post.root.guid),
|
|
:method => :post,
|
|
:remote => true,
|
|
:confirm => t('reshares.reshare.reshare_confirmation', :author => post.root.author.name)
|
|
else
|
|
link_to t("reshares.reshare.reshare_original"),
|
|
reshares_path(:root_guid => post.guid),
|
|
:method => :post,
|
|
:remote => true,
|
|
:confirm => t('reshares.reshare.reshare_confirmation', :author => post.author.name)
|
|
end
|
|
end
|
|
end
|