mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
continue working on exit from room
This commit is contained in:
@@ -4,6 +4,7 @@ import { ChatService } from 'src/app/services/chat.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
import { SetRoomOwnerPage } from 'src/app/modals/set-room-owner/set-room-owner.page';
|
||||
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -22,7 +23,8 @@ export class ChatPopoverPage implements OnInit {
|
||||
private navParams: NavParams,
|
||||
private chatService: ChatService,
|
||||
private toastService: ToastService,
|
||||
public ThemeService: ThemeService
|
||||
public ThemeService: ThemeService,
|
||||
public wsChatMethodsService: WsChatMethodsService,
|
||||
) {
|
||||
this.roomId = this.navParams.get('roomId');
|
||||
this.members = this.navParams.get('members');
|
||||
@@ -58,21 +60,45 @@ export class ChatPopoverPage implements OnInit {
|
||||
cssClass: classs,
|
||||
backdropDismiss: true,
|
||||
componentProps: {
|
||||
room: this.room,
|
||||
roomId: this.roomId,
|
||||
members: this.members,
|
||||
}
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss().then((res)=>{
|
||||
this.leaveGroup();
|
||||
});
|
||||
}
|
||||
|
||||
leaveGroup(){
|
||||
console.log('leave');
|
||||
async leaveGroup(){
|
||||
|
||||
let body = { "roomId":this.roomId, }
|
||||
|
||||
this.chatService.getRoomInfo(this.roomId).subscribe(room=>{
|
||||
let res:any = await this.wsChatMethodsService.leaveRoom(this.roomId);
|
||||
|
||||
console.log(res.error.error);
|
||||
|
||||
if(res.error){
|
||||
if(res.error.error = "error-you-are-last-owner"){
|
||||
this.toastService._badRequest("Você é o último administrador do grupo. Por favor, defina o novo administrador antes de sair da grupo.");
|
||||
|
||||
this.setRoomOwner();
|
||||
}
|
||||
else if(res.error.error == 'error-user-not-in-room'){
|
||||
this.toastService._badRequest("Você já não esta nesta conversa");
|
||||
}
|
||||
else{
|
||||
this.toastService._badRequest("Não foi possível sair do grupo");
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.close('leave');
|
||||
}
|
||||
|
||||
this.close('leave');
|
||||
|
||||
|
||||
/* this.chatService.getRoomInfo(this.roomId).subscribe(room=>{
|
||||
this.room = room['room'];
|
||||
|
||||
if(this.room.t === 'p'){
|
||||
@@ -117,7 +143,7 @@ export class ChatPopoverPage implements OnInit {
|
||||
//loader.remove()
|
||||
});
|
||||
}
|
||||
});
|
||||
}); */
|
||||
}
|
||||
|
||||
//Delete
|
||||
|
||||
Reference in New Issue
Block a user