<commit_before>class ChatsController
  list: undefined

  constructor: (@$rootScope, @$scope, @$timeout, @$mdSidenav, @actorService) ->
    console.log '[AW]ChatsController constructor'
    console.log '[AW]ChatsController constructor: @isLoggedIn', @actorService.isLoggedIn
    if @actorService.isLoggedIn
      @bindDialogs()
    @$scope.$on 'actorLoggedIn', =>
      console.log '[AW]ChatsController constructor: actorLoggedIn fired.'
      @bindDialogs()

  bindDialogs: ->
    console.log '[AW]ChatsController bindDialogs'
    @actorService.bindDialogs (items) => @renderDialogs items

  renderDialogs: (dialogs) ->
    console.log '[AW]ChatsController renderDialogs'
    console.log '[AW]ChatsController renderDialogs: dialogs:', dialogs
    @$timeout =>
#      list.forEach (item) ->
#        console.log item
#        @getUnreadMessages (item.peer.id)
      @list = dialogs
      @$rootScope.$broadcast 'renderDialogs'

  selectChat: (peer) ->
    console.log '[AW]ChatsController selectChat'
    console.log '[AW]ChatsController selectChat: peer:', peer
    if @actorService.currentPeer
      console.log '[AW]ChatsController selectChat: conversation already opened: unbind...'
      @actorService.unbindChat @actorService.currentPeer
      @actorService.onConversationClosed @actorService.currentPeer

    @actorService.bindChat peer
    @actorService.onConversationOpen peer

    # Close sidebar
    @$mdSidenav('left').close()

#  getUnreadMessages: (peer) ->
#    console.log '[AW]ChatsController getUnreadMessages'
#    console.log '[AW]ChatsController getUnreadMessages'
#    console.log @actorService.messenger.g.messenger.angularModule.dialogsList.values.array



ChatsController.$inject = [
    '$rootScope'
    '$scope'
    '$timeout'
    '$mdSidenav'
    'actorService'
  ]

angular
  .module 'actorWeb'
  .controller 'chatsController', ChatsController<commit_msg>feat(web): do nothing when same dialog selected;<commit_after>class ChatsController
  list: undefined

  constructor: (@$rootScope, @$scope, @$timeout, @$mdSidenav, @actorService) ->
    console.log '[AW]ChatsController constructor'
    console.log '[AW]ChatsController constructor: @isLoggedIn', @actorService.isLoggedIn
    if @actorService.isLoggedIn
      @bindDialogs()
    @$scope.$on 'actorLoggedIn', =>
      console.log '[AW]ChatsController constructor: actorLoggedIn fired.'
      @bindDialogs()

  bindDialogs: ->
    console.log '[AW]ChatsController bindDialogs'
    @actorService.bindDialogs (items) => @renderDialogs items

  renderDialogs: (dialogs) ->
    console.log '[AW]ChatsController renderDialogs'
    console.log '[AW]ChatsController renderDialogs: dialogs:', dialogs
    @$timeout =>
      @list = dialogs
      @$rootScope.$broadcast 'renderDialogs'

  selectChat: (peer) ->
    console.log '[AW]ChatsController selectChat'
    console.log '[AW]ChatsController selectChat: peer:', peer
    if @actorService.currentPeer == peer
      console.log '[AW]ChatsController selectChat: this peer already selected.'
      return
    if @actorService.currentPeer
      console.log '[AW]ChatsController selectChat: conversation already opened: unbind...'
      @actorService.unbindChat @actorService.currentPeer
      @actorService.onConversationClosed @actorService.currentPeer

    @actorService.bindChat peer
    @actorService.onConversationOpen peer

    # Close sidebar
    @$mdSidenav('left').close()

#  getUnreadMessages: (peer) ->
#    console.log '[AW]ChatsController getUnreadMessages'
#    console.log '[AW]ChatsController getUnreadMessages'
#    console.log @actorService.messenger.g.messenger.angularModule.dialogsList.values.array



ChatsController.$inject = [
    '$rootScope'
    '$scope'
    '$timeout'
    '$mdSidenav'
    'actorService'
  ]

angular
  .module 'actorWeb'
  .controller 'chatsController', ChatsController
{'fraction_non_alphanumeric': 0.11803022407503909, 'fraction_numerical': 0.0, 'mean_word_length': 4.20189701897019, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '3517564', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1150, 'n_words': 230}