2016-09-04 04:51:12 -04:00
|
|
|
module AwardEmojiHelper
|
|
|
|
def toggle_award_url(awardable)
|
2017-04-27 06:41:26 -04:00
|
|
|
return url_for([:toggle_award_emoji, awardable]) unless @project || awardable.is_a?(Note)
|
2016-10-13 07:01:27 -04:00
|
|
|
|
|
|
|
if awardable.is_a?(Note)
|
2016-10-19 15:58:12 -04:00
|
|
|
# We render a list of notes very frequently and calling the specific method is a lot faster than the generic one (4.5x)
|
2017-04-27 06:41:26 -04:00
|
|
|
if awardable.for_personal_snippet?
|
|
|
|
toggle_award_emoji_snippet_note_path(awardable.noteable, awardable)
|
|
|
|
else
|
2017-06-29 13:06:35 -04:00
|
|
|
toggle_award_emoji_project_note_path(@project, awardable.id)
|
2017-04-27 06:41:26 -04:00
|
|
|
end
|
2016-09-04 04:51:12 -04:00
|
|
|
else
|
2016-10-13 07:01:27 -04:00
|
|
|
url_for([:toggle_award_emoji, @project.namespace.becomes(Namespace), @project, awardable])
|
2016-09-04 04:51:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|