<commit_before>class PrivateMessageListItemView extends ActivityListItemView

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

    options.cssClass           = KD.utils.curry 'privatemessage ', options.cssClass
    options.editWidgetClass  or= ReplyInputEditWidget
    options.commentViewClass or= ReplyView
    options.commentSettings    = {}
    {commentSettings}          = options
    commentSettings.channelId  = options.channelId

    super options, data

    @decorate()

    {typeConstant, createdAt} = @getData()

    @likeView = new ReplyLikeView {}, @getData()
    @timeView = new CommentTimeView timeFormat : 'h:MM TT', createdAt

    @commentBox.listPreviousLink.on 'ReachedToTheBeginning', @bound 'showParentPost'


  prepareDefaultBody: (type) -> "has #{type} the chat"


  prepareActivityMessage: ->

    {typeConstant, payload} = @getData()
    {addedBy, initialParticipants} = payload if payload

    # get default join/leave message body
    switch typeConstant
      when 'join'
        body = @prepareDefaultBody 'joined'  unless initialParticipants
      when 'leave'
        body = @prepareDefaultBody 'left'

    # append who added the user
    body = "#{body} from an invitation by @#{addedBy}" if addedBy

    # when it contains initial participants it contains all the accounts
    # initially added to the conversation
    if initialParticipants
      if initialParticipants.length is 0
        body = "started this conversation"
      else
        body = "started the conversation and invited "
        body = "#{body} @#{participant}," for participant in initialParticipants
        body = body.slice 0, body.length - 1

    return body


  decorate: ->

    {repliesCount, payload, typeConstant} = @getData()

    if typeConstant in ['join', 'leave']
      @getData().body = @prepareActivityMessage()
      @setClass 'join-leave'

    if payload?['system-message']
      @setClass 'join-leave'

    @showParentPost()  if repliesCount < 3


  showParentPost: ->

    @setClass 'with-parent'
    firstReply = @commentBox.listController.getListItems().first

    return  unless firstReply

    if @getData().account._id is firstReply.getData().account._id
      firstReply.setClass 'consequent'



  hideParentPost: -> @unsetClass 'with-parent'


  pistachio: ->
    """
    <div class="activity-content-wrapper clearfix">
      {{> @settingsButton}}
      {{> @avatar}}
      <div class='meta clearfix'>
        {{> @author}} {{> @timeView }} {{> @likeView}}
      </div>
      {{> @editWidgetWrapper}}
      {article.has-markdown{KD.utils.formatContent #(body)}}
      {{> @embedBox}}
    </div>
    """
<commit_msg>activity/messages: hot fix for PR #2584<commit_after>class PrivateMessageListItemView extends ActivityListItemView

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

    options.cssClass           = KD.utils.curry 'privatemessage ', options.cssClass
    options.editWidgetClass  or= ReplyInputEditWidget
    options.commentViewClass or= ReplyView
    options.commentSettings    = {}
    {commentSettings}          = options
    commentSettings.channelId  = options.channelId

    super options, data

    @decorate()

    {typeConstant, createdAt} = @getData()

    @likeView = new ReplyLikeView {}, @getData()
    @timeView = new CommentTimeView timeFormat : 'h:MM TT', createdAt

    @commentBox.listPreviousLink.on 'ReachedToTheBeginning', @bound 'showParentPost'


  prepareDefaultBody: (type) -> "has #{type} the chat"


  prepareActivityMessage: ->

    {typeConstant, payload} = @getData()
    {addedBy, initialParticipants} = payload if payload

    # get default join/leave message body
    switch typeConstant
      when 'join'
        body = @prepareDefaultBody 'joined'  unless initialParticipants
      when 'leave'
        body = @prepareDefaultBody 'left'

    # append who added the user
    body = "#{body} from an invitation by @#{addedBy}" if addedBy

    # when it contains initial participants it contains all the accounts
    # initially added to the conversation
    if initialParticipants
      if initialParticipants.length is 0
        body = "started this conversation"
      else
        body = "started the conversation and invited "
        body = "#{body} @#{participant}," for participant in initialParticipants
        body = body.slice 0, body.length - 1

    return body


  decorate: ->

    {repliesCount, payload, typeConstant} = @getData()

    if typeConstant in ['join', 'leave']
      @getData().body = @prepareActivityMessage()
      @setClass 'join-leave'

    if payload?['system-message']
      @setClass 'join-leave'

    @showParentPost()  if repliesCount < 3


  showParentPost: ->

    @setClass 'with-parent'
    firstReply = @commentBox.listController.getListItems().first

    return  unless firstReply

    if @getData().account._id is firstReply.getData().account._id
      firstReply.setClass 'consequent'



  hideParentPost: -> @unsetClass 'with-parent'


  pistachio: ->
    """
    <div class="activity-content-wrapper clearfix">
      {{> @settingsButton}}
      {{> @avatar}}
      <div class='meta clearfix'>
        {{> @author}} {{> @timeView }} {{> @likeView}}
      </div>
      {{> @editWidgetWrapper}}
      {article.has-markdown{KD.utils.formatContent #(body)}}
      {{> @embedBoxWrapper}}
    </div>
    """

{'fraction_non_alphanumeric': 0.11400037686074996, 'fraction_numerical': 0.0022611644997173543, 'mean_word_length': 3.092521202775636, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 39, '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': '2367147', 'n_tokens_mistral': 1562, 'n_tokens_neox': 1465, 'n_words': 395}