<commit_before>class Kandan.Helpers.Channels
  @all: (options) ->
    $(document).data("channels")

  @getCollection: ->
    $(document).data("channelsCollection")

  @setCollection: (collection) ->
    $(document).data("channelsCollection", collection)
    $(document).data("channels", collection.toJSON())

  @options:
    autoScrollThreshold: 0.90

  @pastAutoScrollThreshold: (channelId) ->
    currentPosition     = @currentScrollPosition channelId
    totalHeight         = $(document).height() - $(window).height()
    scrollPercentage    = (currentPosition) / (totalHeight)
    scrollPercentage > @options.autoScrollThreshold

  @scrollToLatestMessage: (channelId) ->
    if channelId
      theScrollArea = @channelPane(channelId)
      theScrollArea.scrollTop(theScrollArea.prop('scrollHeight'))
    else
      $('.channels-pane').scrollTop($('.channels-pane').prop('scrollHeight'))

  @currentScrollPosition: (channelId) ->
    $('channels-pane').scrollTop()

  @channelPane: (channelId) ->
    $("#channels-#{channelId}")

  @channelActivitiesEl: (channelId) ->
    $("#channel-activities-#{channelId}")

  @channelPaginationEl: (channelId) ->
    $("#channels-#{channelId} .pagination")

  @getActiveChannelId: ->
    $(document).data('active-channel-id')

  @confirmDeletion: ->
    return confirm("Really delete the channel?")

  @flushActivities: (channelId) ->
    $channelActivities = $("#channel-activities-#{channelId}")
    if $channelActivities.children().length == Kandan.options().per_page + 1
      $channelActivities.children().first().remove()
      oldest = $channelActivities.children().first().data("activity-id")
      $channelActivities.prev().data("oldest", oldest)
      @channelPaginationEl(channelId).show()<commit_msg>Fixed auto-scroll to latest message when new activity appears.<commit_after>class Kandan.Helpers.Channels
  @all: (options) ->
    $(document).data("channels")

  @getCollection: ->
    $(document).data("channelsCollection")

  @setCollection: (collection) ->
    $(document).data("channelsCollection", collection)
    $(document).data("channels", collection.toJSON())

  @options:
    autoScrollThreshold: 0.90

  @pastAutoScrollThreshold: (channelId) ->
    currentPosition     = @currentScrollPosition channelId
    totalHeight         = $(document).height() - $(window).height()
    scrollPercentage    = (currentPosition) / (totalHeight)
    scrollPercentage > @options.autoScrollThreshold

  @scrollToLatestMessage: (channelId) ->
    if channelId
      theScrollArea = @channelPane(channelId)
      theScrollArea.scrollTop(theScrollArea.prop('scrollHeight'))
    else
      $('.channels-pane').scrollTop($('.channels-pane').prop('scrollHeight'))

  @currentScrollPosition: (channelId) ->
    $('.channels-pane').scrollTop()

  @channelPane: (channelId) ->
    $("#channels-#{channelId}")

  @channelActivitiesEl: (channelId) ->
    $("#channel-activities-#{channelId}")

  @channelPaginationEl: (channelId) ->
    $("#channels-#{channelId} .pagination")

  @getActiveChannelId: ->
    $(document).data('active-channel-id')

  @confirmDeletion: ->
    return confirm("Really delete the channel?")

  @flushActivities: (channelId) ->
    $channelActivities = $("#channel-activities-#{channelId}")
    if $channelActivities.children().length == Kandan.options().per_page + 1
      $channelActivities.children().first().remove()
      oldest = $channelActivities.children().first().data("activity-id")
      $channelActivities.prev().data("oldest", oldest)
      @channelPaginationEl(channelId).show()
{'fraction_non_alphanumeric': 0.16498032602585722, 'fraction_numerical': 0.0022484541877459247, 'mean_word_length': 4.376132930513595, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '2401067', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1032, 'n_words': 153}