<commit_before>class ChatViewListener < Crabgrass::Hook::ViewListener
  include Singleton

  def chat_message_actions(context)
    return unless logged_in?
    return if context[:message].sender == current_user or context[:message].level == "sys"
    rating = context[:message].ratings.find_by_user_id(current_user.id)
    if rating.nil? or rating.rating != YUCKY_RATING
      if current_user.moderator?
        icon = 'trash_16'
        link_name = 'move message to trash'[:trash_message]
      else
        icon = 'sad_plus_16'
        link_name = :flag_inappropriate.t
      end
      url = url_for(:controller => 'yucky',
                    :chat_message_id => context[:message].id,
                    :action => :add)
      link = link_to_remote(link_name,
                            :url => url,
                            :confirm => :confirm_inappropriate_page.t)
      content_tag(:span, link, {:class => "small_icon #{icon} shy", :id => "flag-#{context[:message].id}"})
    elsif rating.rating == YUCKY_RATING
      url = url_for(:controller => 'yucky',
                    :chat_message_id => context[:message].id,
                    :action => :remove)
      link = link_to_remote(:flag_appropriate.t,
                            :url => url,
                            :confirm => :confirm_inappropriate_page.t)
      content_tag(:span, link, {:class => 'small_icon sad_minus_16 shy', :id => "flag-#{context[:message].id}"})
    end
  end
end
<commit_msg>reload the archive page when flagging a message<commit_after>class ChatViewListener < Crabgrass::Hook::ViewListener
  include Singleton

  def chat_message_actions(context)
    return unless logged_in?
    return if context[:message].sender == current_user or context[:message].level == "sys"
    rating = context[:message].ratings.find_by_user_id(current_user.id)
    if rating.nil? or rating.rating != YUCKY_RATING
      if current_user.moderator?
        icon = 'trash_16'
        link_name = 'move message to trash'[:trash_message]
        confirm = nil
      else
        icon = 'sad_plus_16'
        link_name = :flag_inappropriate.t
        confirm = :confirm_inappropriate_page.t
      end
      success = context[:params][:action] == "say" ? nil: "window.location.reload();"
      url = url_for(:controller => 'yucky',
                    :chat_message_id => context[:message].id,
                    :action => :add)
      link = link_to_remote(link_name,
                            :url => url,
                            :confirm => confirm,
                            :success => success)
      content_tag(:span, link, {:class => "small_icon #{icon} shy", :id => "flag-#{context[:message].id}"})
    elsif rating.rating == YUCKY_RATING
      confirm = current_user.moderator? ? nil : :confirm_inappropriate_page.t
      success = context[:params][:action] == "say" ? nil: "window.location.reload();"
      url = url_for(:controller => 'yucky',
                    :chat_message_id => context[:message].id,
                    :action => :remove)

      link = link_to_remote(:flag_appropriate.t,
                            :url => url,
                            :confirm => confirm,
                            :success => success)
      content_tag(:span, link, {:class => 'small_icon sad_minus_16 shy', :id => "flag-#{context[:message].id}"})
    end
  end
end

{'fraction_non_alphanumeric': 0.1260053619302949, 'fraction_numerical': 0.0035746201966041107, 'mean_word_length': 2.2760975609756096, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4657182', 'n_tokens_mistral': 1002, 'n_tokens_neox': 966, 'n_words': 203}