2020-12-28 10:11:00 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2021-01-27 11:23:57 +01:00
|
|
|
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
|
|
|
|
|
import { EditGroupPage } from 'src/app/pages/chat/edit-group/edit-group.page';
|
2021-01-20 10:23:59 +01:00
|
|
|
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-04-13 14:45:56 +01:00
|
|
|
roomId:string;
|
|
|
|
|
room: any;
|
2020-12-28 10:11:00 +01:00
|
|
|
|
2021-01-04 16:03:41 +01:00
|
|
|
constructor(
|
|
|
|
|
private popoverController: PopoverController,
|
2021-01-27 11:23:57 +01:00
|
|
|
private modalController: ModalController,
|
2021-01-20 10:23:59 +01:00
|
|
|
private navParams: NavParams,
|
|
|
|
|
private chatService: ChatService,
|
|
|
|
|
) {
|
2021-04-13 14:45:56 +01:00
|
|
|
this.roomId = this.navParams.get('roomId');
|
2021-01-20 10:23:59 +01:00
|
|
|
}
|
2020-12-28 10:11:00 +01:00
|
|
|
|
|
|
|
|
ngOnInit() {
|
2021-04-13 14:45:56 +01:00
|
|
|
console.log(this.roomId);
|
2021-01-20 10:23:59 +01:00
|
|
|
|
2020-12-28 10:11:00 +01:00
|
|
|
}
|
2021-01-04 16:03:41 +01:00
|
|
|
close(){
|
2021-03-18 09:25:59 +01:00
|
|
|
if( window.innerWidth <= 1024){
|
2021-04-15 23:57:14 +01:00
|
|
|
//this.popoverController.dismiss();
|
|
|
|
|
this.modalController.dismiss('cancel');
|
2021-03-18 09:25:59 +01:00
|
|
|
}
|
|
|
|
|
else{
|
2021-04-15 23:57:14 +01:00
|
|
|
this.modalController.dismiss('cancel');
|
2021-03-18 09:25:59 +01:00
|
|
|
}
|
2021-01-04 16:03:41 +01:00
|
|
|
}
|
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(){
|
2021-04-15 23:57:14 +01:00
|
|
|
console.log('leave');
|
|
|
|
|
|
2021-04-13 14:45:56 +01:00
|
|
|
let body = { "roomId":this.roomId, }
|
|
|
|
|
|
|
|
|
|
this.chatService.getRoomInfo(this.roomId).subscribe(room=>{
|
|
|
|
|
this.room = room['room'];
|
|
|
|
|
|
|
|
|
|
if(this.room.t === 'p'){
|
2021-04-20 17:18:57 +01:00
|
|
|
this.chatService.leaveGroup(body).subscribe(res=>{
|
2021-04-13 14:45:56 +01:00
|
|
|
console.log(res);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else{
|
2021-04-20 17:18:57 +01:00
|
|
|
this.chatService.leaveChannel(body).subscribe(res=>{
|
2021-04-13 14:45:56 +01:00
|
|
|
console.log(res);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-04-15 23:57:14 +01:00
|
|
|
this.modalController.dismiss('leave');
|
2021-01-20 16:58:04 +01:00
|
|
|
}
|
|
|
|
|
//Delete
|
|
|
|
|
deleteGroup(){
|
2021-04-13 14:45:56 +01:00
|
|
|
let body = { "roomId":this.roomId, }
|
|
|
|
|
this.chatService.getRoomInfo(this.roomId).subscribe(room=>{
|
|
|
|
|
this.room = room['room'];
|
|
|
|
|
|
|
|
|
|
if(this.room.t === 'p'){
|
|
|
|
|
this.chatService.deleteGroup(body).subscribe(res=>{
|
|
|
|
|
console.log(res);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this.chatService.deleteChannel(body).subscribe(res=>{
|
|
|
|
|
console.log(res);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-04-15 23:57:14 +01:00
|
|
|
this.modalController.dismiss('delete');
|
2021-01-20 10:23:59 +01:00
|
|
|
}
|
2021-04-14 14:10:17 +01:00
|
|
|
|
2021-01-27 11:23:57 +01:00
|
|
|
async openChangeGroupName(){
|
2021-04-16 09:57:08 +01:00
|
|
|
this.modalController.dismiss('edit');
|
|
|
|
|
/* const modal = await this.modalController.create({
|
2021-01-27 11:23:57 +01:00
|
|
|
component: EditGroupPage,
|
|
|
|
|
componentProps: {
|
2021-04-14 13:56:38 +01:00
|
|
|
roomId: this.roomId,
|
2021-01-27 11:23:57 +01:00
|
|
|
},
|
|
|
|
|
cssClass: 'contacts',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await modal.present();
|
2021-01-27 16:01:49 +01:00
|
|
|
modal.onDidDismiss().then((res)=>{
|
|
|
|
|
console.log(res.data);
|
2021-04-15 23:57:14 +01:00
|
|
|
this.modalController.dismiss(res.data);
|
2021-04-16 09:57:08 +01:00
|
|
|
}); */
|
2021-01-27 11:23:57 +01:00
|
|
|
}
|
2021-01-20 10:23:59 +01:00
|
|
|
|
2020-12-28 10:11:00 +01:00
|
|
|
}
|