<commit_before>class GenericNotificationView extends Backbone.Marionette.Layout
  tagName: "li"
  className: "activity"
  template: "notifications/generic"
  templateHelpers: ->
    user: (new User @model.get('user')).toJSON()

  events:
    'click a': 'click'

  initialEvents: -> false # stop layout from refreshing after model/collection update
                  # no longer needed in marionette 1.0

  click: (e) ->
    @trigger 'activityActivated'
    return Backbone.View.prototype.defaultClickHandler(e)

  onRender: ->
    @$el.addClass "unread" if @model.get("unread") is true

  markAsRead: -> @$el.removeClass "unread"

class NotificationAddedEvidenceView extends GenericNotificationView
  template: "notifications/added_evidence"

class NotificationAddedSubchannelView extends GenericNotificationView
  template: "notifications/added_subchannel"

  regions:
    addBackRegion: ".js-region-add-back"

  initialize: ->
    @activity = @model.get('activity')

  other_channel: ->
    new Channel
      id: @activity.to_channel_id
      containing_channel_ids: @activity.to_channel_containing_channel_ids

  onRender: ->
    super()

    # TODO clean this behaviour.
    # We don't want Topics with duplicate slug in the SuggestedTopics collection
    topic1 = @channel_as_topic()
    topic2 = @other_channel_as_topic()

    same_slug_title = topic1.get('slug_title') == topic2.get('slug_title')

    topics = [topic1]
    topics.push(topic2) unless same_slug_title
    # end

    suggested_topics = new SuggestedTopics topics
    @addBackRegion.show new AddChannelToChannelsButtonView
                                model: @other_channel()
                                suggested_topics: suggested_topics

<commit_msg>Moved suggested_topics to own cleaner function<commit_after>class GenericNotificationView extends Backbone.Marionette.Layout
  tagName: "li"
  className: "activity"
  template: "notifications/generic"
  templateHelpers: ->
    user: (new User @model.get('user')).toJSON()

  events:
    'click a': 'click'

  initialEvents: -> false # stop layout from refreshing after model/collection update
                  # no longer needed in marionette 1.0

  click: (e) ->
    @trigger 'activityActivated'
    return Backbone.View.prototype.defaultClickHandler(e)

  onRender: ->
    @$el.addClass "unread" if @model.get("unread") is true

  markAsRead: -> @$el.removeClass "unread"

class NotificationAddedEvidenceView extends GenericNotificationView
  template: "notifications/added_evidence"

class NotificationAddedSubchannelView extends GenericNotificationView
  template: "notifications/added_subchannel"

  regions:
    addBackRegion: ".js-region-add-back"

  initialize: ->
    @activity = @model.get('activity')

  suggested_topics: ->
    topic1 = new Topic
                  title:      @activity.channel_title,
                  slug_title: @activity.channel_slug_title

    topic2 = new Topic
                  title:      @activity.to_channel_title,
                  slug_title: @activity.to_channel_slug_title

    return new SuggestedTopics [topic1, topic2]

  other_channel: ->
    new Channel
      id: @activity.to_channel_id
      containing_channel_ids: @activity.to_channel_containing_channel_ids

  onRender: ->
    super()
    @addBackRegion.show new AddChannelToChannelsButtonView
                                model: @other_channel()
                                suggested_topics: @suggested_topics()
{'fraction_non_alphanumeric': 0.0897510133178923, 'fraction_numerical': 0.004053271569195136, 'mean_word_length': 3.2134146341463414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '3010847', 'n_tokens_mistral': 1016, 'n_tokens_neox': 980, 'n_words': 225}