import { Component, OnInit } from '@angular/core';
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
import { ChatService } from 'src/app/services/chat.service';
import { ThemeService } from 'src/app/services/theme.service'


@Component({
  selector: 'app-messages-options',
  templateUrl: './messages-options.page.html',
  styleUrls: ['./messages-options.page.scss'],
})
export class MessagesOptionsPage implements OnInit {

  roomId:string;

  constructor(
    private popoverController: PopoverController,
    private modalController: ModalController,
    private chatService: ChatService,
    private navParams: NavParams,
    public ThemeService: ThemeService
  )
  {
    this.roomId = this.navParams.get('roomId');
  }

  ngOnInit() {
  }

  close(){
    if( window.innerWidth <= 701){
      this.modalController.dismiss();
      this.popoverController.dismiss();
    }
    else{
      this.modalController.dismiss();
      this.popoverController.dismiss();
    }
  }

  closeChatRoom(){
    let body = { "roomId": this.roomId }
    this.chatService.removeChatRoom(body).subscribe(res=>{
      console.log(res);
    });
    this.close();
  }

}
