<commit_before>class OpinionViewHeader extends JView

  constructor:(options = {}, data)->

    options.cssClass       = "show-more-opinions in"
    options.itemTypeString = options.itemTypeString or "answers"

    super options, data

    data = @getData()

    @maxCommentToShow = 5
    @oldCount         = data.repliesCount
    @newCount         = 0
    @onListCount      = if data.repliesCount > @maxCommentToShow then @maxCommentToShow else data.repliesCount

    unless data.repliesCount? and data.repliesCount > @maxCommentToShow
      @onListCount = data.repliesCount
      @hide()

    @hide() if data.repliesCount is 0

    list = @getDelegate()

    list.on "AllOpinionsWereAdded", =>
      @newCount = 0
      @onListCount = @getData().repliesCount
      @updateNewCount()
      @hide()
      @loader.destroy()

    @allItemsLink = new KDCustomHTMLView
      tagName   : "a"
      cssClass  : "all-count"
      partial   : "View #{@maxCommentToShow} more #{@getOptions().itemTypeString}"
      click     : =>
        @loader.show()
        list.emit "AllOpinionsLinkWasClicked", @
    , data

    list.on "RelativeOpinionsWereAdded",  =>
      remainingOpinions = @getData().repliesCount-@getDelegate().items.length
      if (remainingOpinions)<@maxCommentToShow
        @allItemsLink.updatePartial "View last #{remainingOpinions} #{@getOptions().itemTypeString}"
      if @getDelegate().items.length<@getData().repliesCount
        @loader.hide()
      else
        @loader.destroy()
        @allItemsLink.destroy()

    @loader = new KDLoaderView
      cssClass      : "opinion-loader hidden"
      size          :
        width       : 12
      loaderOptions :
        color       : "#444"
        shape       : "spiral"
        diameter    : 30
        density     : 30
        range       : 0.4
        speed       : 2
        FPS         : 24

    @newItemsLink = new KDCustomHTMLView
      tagName   : "a"
      cssClass  : "new-items"
      click     : =>
        list.emit "AllOpinionsLinkWasClicked", @

  ownCommentArrived:->

    # Get correct number of items in list from controller
    # I'm not sure maybe its not a good idea
    @onListCount = @parent.commentController?.getItemCount?()

    # If there are same number of comments in list with total
    # comment size means we don't need to show new item count
    @newItemsLink.unsetClass('in')

    # If its our comments so it's not a new comment
    if @newCount > 0 then @newCount--

    @updateNewCount()

  ownCommentDeleted:->
    if @newCount > 0
      @newCount++

  render:->

    # Get correct number of items in list from controller
    # I'm not sure maybe its not a good idea
    if @parent?.commentController?.getItemCount?()
      @onListCount = @parent.commentController.getItemCount()
    _newCount = @getData().repliesCount

    # Show View all bla bla link if there are more comments
    # than maxCommentToShow
    @show() if _newCount > @maxCommentToShow and @onListCount < _newCount

    # Check the oldCount before update anything
    # if its less means someone deleted a comment
    # otherwise it meanse we have a new comment
    # if nothing changed it means user clicked like button
    # so we don't need to touch anything
    if _newCount > @oldCount
      @newCount++
    else if _newCount < @oldCount
      if @newCount > 0 then @newCount--

    # If the count is changed then we need to update UI
    if _newCount isnt @oldCount
      @oldCount = _newCount
      @utils.wait => @updateNewCount()

    super

  updateNewCount:->

    # If there is no comments so we can not have new comments
    if @oldCount is 0 then @newCount = 0

    # If we have comments more than 0 we should show the new item link
    if @newCount > 0
      # @show()
      @newItemsLink.updatePartial "#{@newCount} new"
      @newItemsLink.setClass('in')
    else
      @newItemsLink.unsetClass('in')

    if @onListCount > @oldCount
      @onListCount = @oldCount

    if @onListCount is @getData().repliesCount
      @newCount = 0

    if @onListCount is @oldCount and @newCount is 0
      @hide()
    else
      # @show()

  hide:->
    @unsetClass "in"
    super

  show:-><commit_msg>removed unused methods from commentviewheader inheritance<commit_after>class OpinionViewHeader extends JView

  constructor:(options = {}, data)->

    options.cssClass       = "show-more-opinions in"
    options.itemTypeString = options.itemTypeString or "answers"

    super options, data

    data = @getData()

    @maxCommentToShow = 5
    @oldCount         = data.repliesCount
    @newCount         = 0
    @onListCount      = if data.repliesCount > @maxCommentToShow then @maxCommentToShow else data.repliesCount

    unless data.repliesCount? and data.repliesCount > @maxCommentToShow
      @onListCount = data.repliesCount
      @hide()

    @hide() if data.repliesCount is 0

    list = @getDelegate()

    list.on "AllOpinionsWereAdded", =>
      @newCount = 0
      @onListCount = @getData().repliesCount
      @updateNewCount()
      @hide()
      @loader.destroy()

    @allItemsLink = new KDCustomHTMLView
      tagName   : "a"
      cssClass  : "all-count"
      partial   : "View #{@maxCommentToShow} more #{@getOptions().itemTypeString}"
      click     : =>
        @loader.show()
        list.emit "AllOpinionsLinkWasClicked", @
    , data

    list.on "RelativeOpinionsWereAdded",  =>
      remainingOpinions = @getData().repliesCount-@getDelegate().items.length
      if (remainingOpinions)<@maxCommentToShow
        @allItemsLink.updatePartial "View last #{remainingOpinions} #{@getOptions().itemTypeString}"
      if @getDelegate().items.length<@getData().repliesCount
        @loader.hide()
      else
        @loader.destroy()
        @allItemsLink.destroy()

    @loader = new KDLoaderView
      cssClass      : "opinion-loader hidden"
      size          :
        width       : 12
      loaderOptions :
        color       : "#444"
        shape       : "spiral"
        diameter    : 30
        density     : 30
        range       : 0.4
        speed       : 2
        FPS         : 24

    @newItemsLink = new KDCustomHTMLView
      tagName   : "a"
      cssClass  : "new-items"
      click     : =>
        list.emit "AllOpinionsLinkWasClicked", @

  hide:->
    @unsetClass "in"
    super

  show:->
{'fraction_non_alphanumeric': 0.09747979077508322, 'fraction_numerical': 0.007132667617689016, 'mean_word_length': 2.3599574014909477, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5041021', 'n_tokens_mistral': 1963, 'n_tokens_neox': 1890, 'n_words': 509}