/*
    Safepost Messaging System https://safepo.st
    Copyright (C) 2014 Ross Barclay

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/*
 */
var ContactsController = Ember.ArrayController.extend( {
  needs: [ 'contacts', 'application' ],
  itemController: 'contact',
  hideBlockedContacts: true,
  onlineContactsCount: function () {
    'use strict';
    return this.get( 'content' ).reduce( function ( previousValue, contact ) {
      return ( contact.get( 'isOnline' ) && !contact.get( 'isSelf' ) ) ? previousValue + 1 : previousValue;
    }, 0 );
  }.property( 'content.@each.isOnline' ),
  blockedContactsCount: function () {
    'use strict';
    return this.get( 'content' ).reduce( function ( previousValue, contact ) {
      return contact.get( 'isBlocked' ) ? previousValue + 1 : previousValue;
    }, 0 );
  }.property( 'content.@each.isBlocked' )
} );
export
default ContactsController;
