<commit_before>class CommentViewHeader extends JView

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

    options.cssClass       = "show-more-comments"
    options.itemTypeString = options.itemTypeString or "comments"

    super options, data

    data = @getData()

    @maxCommentToShow = 3
    @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()

    list = @getDelegate()

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

    @allItemsLink = new KDCustomHTMLView
      tagName   : "a"
      cssClass  : "all-count"
      pistachio : "View all {{#(repliesCount)}} #{@getOptions().itemTypeString}..."
      click     : => list.emit "AllCommentsLinkWasClicked", @
    , data

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

  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<commit_msg>Dont call it if its not exists<commit_after>class CommentViewHeader extends JView

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

    options.cssClass       = "show-more-comments"
    options.itemTypeString = options.itemTypeString or "comments"

    super options, data

    data = @getData()

    @maxCommentToShow = 3
    @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()

    list = @getDelegate()

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

    @allItemsLink = new KDCustomHTMLView
      tagName   : "a"
      cssClass  : "all-count"
      pistachio : "View all {{#(repliesCount)}} #{@getOptions().itemTypeString}..."
      click     : => list.emit "AllCommentsLinkWasClicked", @
    , data

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

  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
{'fraction_non_alphanumeric': 0.0878039367039753, 'fraction_numerical': 0.0023157082207641835, 'mean_word_length': 2.74765003615329, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 31, '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': '5933012', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1517, 'n_words': 499}