continue working on exit from room

This commit is contained in:
tiago.kayaya
2022-01-26 09:19:54 +01:00
parent c6ec2abc1f
commit 58a32f45d4
7 changed files with 161 additions and 19 deletions
@@ -9,7 +9,7 @@
</button>
</div>
<div class="div-title">
<ion-label class="title">Promover para Administrador</ion-label>
<ion-label class="title">Nomear novo administrador</ion-label>
</div>
</div>
</div>
@@ -3,6 +3,7 @@ import { Component, OnInit } from '@angular/core';
import { ModalController, NavParams } from '@ionic/angular';
import { AuthService } from 'src/app/services/auth.service';
import { ChatService } from 'src/app/services/chat.service';
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
import { ThemeService } from 'src/app/services/theme.service'
import { ToastService } from 'src/app/services/toast.service';
@@ -14,7 +15,7 @@ import { ToastService } from 'src/app/services/toast.service';
export class SetRoomOwnerPage implements OnInit {
textSearch:string = "";
room:any;
roomId:any;
members:any;
constructor(
@@ -25,13 +26,14 @@ export class SetRoomOwnerPage implements OnInit {
private navParams: NavParams,
public ThemeService: ThemeService,
private toastService: ToastService,
public wsChatMethodsService: WsChatMethodsService,
) {
this.room = this.navParams.get('room');
this.roomId = this.navParams.get('roomId');
this.members = this.navParams.get('members');
}
ngOnInit() {
console.log(this.room);
console.log(this.members);
}
@@ -57,23 +59,43 @@ export class SetRoomOwnerPage implements OnInit {
return null;
}
setRoomOwner(user:any){
async setRoomOwner(user:any){
console.log(user);
console.log(this.room);
let res:any = await this.wsChatMethodsService.addRoomOwner(this.roomId, user._id);
console.log(res);
if(res.error){
if(res.error.error == 'error-user-already-owner'){
this.toastService._badRequest('Este utilizador já é administrador');
}
else{
this.toastService._badRequest('Não foi possível completar a ação, por favor tente novamente.');
}
}
else{
this.modalController.dismiss('success');
}
/*
let body = {
"roomId": this.room._id,
"roomId": this.roomId,
"userId": user._id
}
this.chatService.addGroupOwner(body).subscribe((res)=>{
alert('here');
console.log(res);
this.close();
}, (error) => {
this.toastService._badRequest('Não foi possível completar a ação, por favor tente novamente.');
});
this.toastService._successMessage('Operação realizada com sucesso');
}, (e) => {
if(e.error.errorType == 'error-user-already-owner'){
this.toastService._badRequest('Este utilizador já é administrador');
}
else{
this.toastService._badRequest('Não foi possível completar a ação, por favor tente novamente.');
}
}); */
}