2020-12-28 10:11:00 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2021-01-20 10:23:59 +01:00
|
|
|
import { NavParams, PopoverController } from '@ionic/angular';
|
|
|
|
|
import { ChatService } from 'src/app/services/chat.service';
|
2020-12-28 10:11:00 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-chat-popover',
|
|
|
|
|
templateUrl: './chat-popover.page.html',
|
|
|
|
|
styleUrls: ['./chat-popover.page.scss'],
|
|
|
|
|
})
|
|
|
|
|
export class ChatPopoverPage implements OnInit {
|
2021-01-20 10:23:59 +01:00
|
|
|
room:any;
|
2020-12-28 10:11:00 +01:00
|
|
|
|
2021-01-04 16:03:41 +01:00
|
|
|
constructor(
|
|
|
|
|
private popoverController: PopoverController,
|
2021-01-20 10:23:59 +01:00
|
|
|
private navParams: NavParams,
|
|
|
|
|
private chatService: ChatService,
|
|
|
|
|
) {
|
|
|
|
|
this.room = this.navParams.get('room');
|
|
|
|
|
}
|
2020-12-28 10:11:00 +01:00
|
|
|
|
|
|
|
|
ngOnInit() {
|
2021-01-20 10:23:59 +01:00
|
|
|
console.log(this.room);
|
|
|
|
|
|
2020-12-28 10:11:00 +01:00
|
|
|
}
|
2021-01-04 16:03:41 +01:00
|
|
|
close(){
|
|
|
|
|
this.popoverController.dismiss();
|
|
|
|
|
}
|
2020-12-28 10:11:00 +01:00
|
|
|
|
2021-01-20 10:23:59 +01:00
|
|
|
//Top menu options
|
2021-01-20 16:58:04 +01:00
|
|
|
//Close
|
2021-01-20 10:23:59 +01:00
|
|
|
leaveGroup(){
|
|
|
|
|
let body = { "roomId":this.room._id, }
|
|
|
|
|
if(this.room.t === 'p'){
|
|
|
|
|
this.chatService.closeGroup(body).subscribe(res=>{
|
|
|
|
|
console.log(res);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this.chatService.closeChannel(body).subscribe(res=>{
|
|
|
|
|
console.log(res);
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-01-20 16:58:04 +01:00
|
|
|
this.popoverController.dismiss(true);
|
|
|
|
|
}
|
|
|
|
|
//Delete
|
|
|
|
|
deleteGroup(){
|
|
|
|
|
let body = { "roomId":this.room._id, }
|
|
|
|
|
if(this.room.t === 'p'){
|
|
|
|
|
this.chatService.deleteGroup(body).subscribe(res=>{
|
|
|
|
|
console.log(res);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this.chatService.deleteChannel(body).subscribe(res=>{
|
|
|
|
|
console.log(res);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.popoverController.dismiss(true);
|
2021-01-20 10:23:59 +01:00
|
|
|
}
|
|
|
|
|
|
2020-12-28 10:11:00 +01:00
|
|
|
}
|