2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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?
|
2019-12-10 16:08:01 -05:00
|
|
|
gitlab_toggle_award_emoji_snippet_note_path(awardable.noteable, awardable)
|
2017-04-27 06:41:26 -04:00
|
|
|
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
|
2020-07-27 08:09:50 -04:00
|
|
|
url_for([:toggle_award_emoji, @project, awardable])
|
2016-09-04 04:51:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
|
|
|
AwardEmojiHelper.prepend_if_ee('EE::AwardEmojiHelper')
|