BigW Consortium Gitlab

award_emoji_helper.rb 639 Bytes
Newer Older
1 2
module AwardEmojiHelper
  def toggle_award_url(awardable)
3
    return url_for([:toggle_award_emoji, awardable]) unless @project || awardable.is_a?(Note)
4 5

    if awardable.is_a?(Note)
6
      # We render a list of notes very frequently and calling the specific method is a lot faster than the generic one (4.5x)
7 8 9
      if awardable.for_personal_snippet?
        toggle_award_emoji_snippet_note_path(awardable.noteable, awardable)
      else
10
        toggle_award_emoji_project_note_path(@project, awardable.id)
11
      end
12
    else
13
      url_for([:toggle_award_emoji, @project.namespace.becomes(Namespace), @project, awardable])
14 15 16
    end
  end
end