<commit_before>class SidebarMessageItemIcon extends JView

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

    options.tagName    = 'span'
    options.cssClass or= 'sidebar-message-icon'
    options.size     or= { width: 24, height: 24 }

    super options, data

    @init()


  init: ->

    { participantCount, participantsPreview } = @getData()

    shouldBeGrouped = no

    if participantCount is 1
      sample = participantsPreview
    else
      sample = participantsPreview.filter (acc) -> return acc._id isnt KD.whoami()._id
      shouldBeGrouped = yes  if participantCount > 2

    origin = sample.first

    if shouldBeGrouped
    then @createGrouped()
    else @createSingle origin

  createSingle: (origin) ->

    { width, height, cssClass } = @getOptions().size

    origin = { constructorName : 'JAccount', id : origin._id }

    @icon = new AvatarStaticView
      size       : { width, height }
      cssClass   : cssClass
      showStatus : yes
      origin     : origin


  createGrouped: ->

    @icon = new KDCustomHTMLView
      tagName  : 'span'

    @setClass 'stacked'

    { width, height, cssClass } = @getOptions().size

    @getParticipantOrigins (origins) =>

      for i in [origins.length - 1..0]
        @icon.addSubView new AvatarStaticView
          size       : { width, height }
          cssClass   : cssClass
          showStatus : yes
          origin     : origins[i]


  getParticipantOrigins: (callback) ->

    { lastMessage, participantsPreview, participantCount } = @getData()

    lastMessageOwner = lastMessage.account

    origins  = [lastMessageOwner]

    filtered = participantsPreview.filter (p) ->
      return not (p._id in [KD.whoami()._id, lastMessageOwner._id])

    origins = origins.concat filtered.slice 0, 2
    origins = origins.map (origin) -> { constructorName : 'JAccount', id : origin._id }

    callback origins


  pistachio: -> "{{> @icon}}"


<commit_msg>sidebar: change size of avatars at chat items<commit_after>class SidebarMessageItemIcon extends JView

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

    options.tagName    = 'span'
    options.cssClass or= 'sidebar-message-icon'
    options.size     or= { width: 20, height: 20 }

    super options, data

    @init()


  init: ->

    { participantCount, participantsPreview } = @getData()

    shouldBeGrouped = no

    if participantCount is 1
      sample = participantsPreview
    else
      sample = participantsPreview.filter (acc) -> return acc._id isnt KD.whoami()._id
      shouldBeGrouped = yes  if participantCount > 2

    origin = sample.first

    if shouldBeGrouped
    then @createGrouped()
    else @createSingle origin

  createSingle: (origin) ->

    { width, height, cssClass } = @getOptions().size

    origin = { constructorName : 'JAccount', id : origin._id }

    @icon = new AvatarStaticView
      size       : { width, height }
      cssClass   : cssClass
      showStatus : yes
      origin     : origin


  createGrouped: ->

    @icon = new KDCustomHTMLView
      tagName  : 'span'

    @setClass 'stacked'

    { width, height, cssClass } = @getOptions().size

    @getParticipantOrigins (origins) =>

      for i in [origins.length - 1..0]
        @icon.addSubView new AvatarStaticView
          size       : { width, height }
          cssClass   : cssClass
          showStatus : yes
          origin     : origins[i]


  getParticipantOrigins: (callback) ->

    { lastMessage, participantsPreview, participantCount } = @getData()

    lastMessageOwner = lastMessage.account

    origins  = [lastMessageOwner]

    filtered = participantsPreview.filter (p) ->
      return not (p._id in [KD.whoami()._id, lastMessageOwner._id])

    origins = origins.concat filtered.slice 0, 2
    origins = origins.map (origin) -> { constructorName : 'JAccount', id : origin._id }

    callback origins


  pistachio: -> "{{> @icon}}"



{'fraction_non_alphanumeric': 0.10459710743801653, 'fraction_numerical': 0.005165289256198347, 'mean_word_length': 2.5467032967032965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '5039788', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1111, 'n_words': 297}