Files
doneit-web/src/app/shared/popover/chat-popover/chat-popover.page.ts
T

95 lines
2.3 KiB
TypeScript
Raw Normal View History

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
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
}
close(){
2021-03-18 09:25:59 +01:00
if( window.innerWidth <= 1024){
this.popoverController.dismiss();
}
else{
this.modalController.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(){
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.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(){
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-01-20 16:58:04 +01:00
this.popoverController.dismiss(true);
2021-01-20 10:23:59 +01:00
}
2021-01-27 11:23:57 +01:00
async openChangeGroupName(){
const modal = await this.modalController.create({
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);
this.popoverController.dismiss(res.data);
2021-01-27 11:23:57 +01:00
});
}
2021-01-20 10:23:59 +01:00
2020-12-28 10:11:00 +01:00
}