import { Component, OnInit, Input } from '@angular/core';
import { ChatUser } from 'app/chat/models/chat-user';
import { ChatUiService } from 'app/chat/services/chat-ui.service';

@Component({
  selector: 'app-chat-contact-list',
  templateUrl: './chat-contact-list.component.html',
  styleUrls: ['./chat-contact-list.component.scss']
})
export class ChatContactListComponent implements OnInit {

  @Input()
  contacts: ChatUser[] = [];

  collapsed: boolean = true;

  get collapseText() {
    return this.collapsed ? 'View All' : 'Collapse All';
  }

  constructor(
    private chatUiService: ChatUiService
  ) { }

  ngOnInit() {
  }

  onContactClick(user) {
    this.chatUiService.startConversation(user);
  }

  toggleCollapsed() {
    this.collapsed = !this.collapsed;
  }

}
