This commit is contained in:
tiago.kayaya
2021-07-23 14:43:51 +01:00
parent 9bcc06add2
commit b5e1ad4201
17 changed files with 194 additions and 203 deletions
@@ -40,11 +40,9 @@ export class GroupContactsPage implements OnInit {
private chatService: ChatService,
private authService: AuthService,
//private navParams: NavParams,
)
)
{
this.authService.userData$.subscribe((res:any)=>{
this.loggedUser=res;
});
this.loggedUser = authService.ValidatedUserChat['data'];
this.textSearch="";
this.dm=null;
this.room=null;
@@ -56,9 +54,9 @@ export class GroupContactsPage implements OnInit {
ngOnInit() {
//this.getRoomInfo();
//this.loadUsers();
this.loadUsers();
console.log(this.roomId);
this.getChatInfo();
this.getChatInfo();
//console.log(this.isGroupCreated);
}
@@ -72,7 +70,7 @@ export class GroupContactsPage implements OnInit {
}
deleteMember(data:any){
console.log(data);
let body = {
"roomId": this.roomId,
"userId": data._id,
@@ -100,7 +98,7 @@ export class GroupContactsPage implements OnInit {
this.chatService.getRoomInfo(this.roomId).subscribe(res=>{
console.log(res);
let room = res['room'];
if(room.t == "p"){
this.chatService.getGroupMembers(this.roomId).subscribe(res=>{
this.members = res['members'];
@@ -148,7 +146,7 @@ export class GroupContactsPage implements OnInit {
}
loadUsers1(members:any){
this.options = {
this.options = {
headers: this.headers,
};
this.chatService.getAllUsers().subscribe((res:any)=>{
@@ -161,7 +159,7 @@ export class GroupContactsPage implements OnInit {
else{
this.contacts = res.users.filter(data => data.username != this.loggedUser.me.username);
}
this.users = this.contacts.sort((a,b) => {
if(a.name < b.name){
return -1;
@@ -172,13 +170,13 @@ export class GroupContactsPage implements OnInit {
return 0;
});
console.log(this.users);
this.showLoader = false;
});
}
loadUsers(){
this.options = {
this.options = {
headers: this.headers,
};
this.chatService.getAllUsers().subscribe((res:any)=>{
@@ -191,7 +189,7 @@ export class GroupContactsPage implements OnInit {
else{
this.contacts = res.users.filter(data => data.username != this.loggedUser.me.username);
}
this.users = this.contacts.sort((a,b) => {
if(a.name < b.name){
return -1;
@@ -202,7 +200,7 @@ export class GroupContactsPage implements OnInit {
return 0;
});
console.log(this.users);
this.showLoader = false;
});
}
@@ -228,7 +226,7 @@ export class GroupContactsPage implements OnInit {
async close(){
this.modalController.dismiss();
if(this.isGroupCreated){
console.log('go to conversa');
console.log('go to conversa');
}
else{
this.modalController.dismiss();
@@ -272,7 +270,7 @@ export class GroupContactsPage implements OnInit {
}
this.chatService.addUserToGroup(body).subscribe(res=>{
console.log(res['success']);
});
});
});
}
@@ -285,14 +283,14 @@ export class GroupContactsPage implements OnInit {
console.log(res['group']);
this.addContacts(res['group']);
this.openGroupMessages(res['group']);
});
}
else{
this.addContacts(this.room);
this.close();
}
this.close();
}
} */
async newGroup(){
@@ -312,7 +310,7 @@ export class GroupContactsPage implements OnInit {
component: GroupMessagesPage,
componentProps: {
room: room,
},
},
cssClass: 'group-messages',
backdropDismiss: false
});
@@ -9,7 +9,7 @@
<button class="btn-no-color" (click)="openGroupMessagesOptions()">
<ion-icon src="assets/images/icons-menu.svg"></ion-icon>
</button>
</div>
</div>
</div>
<div (click)="openGroupContactsPage()" class="header-bottom">
<div class="header-bottom-icon">
@@ -21,12 +21,13 @@ export class GroupMessagesPage implements OnInit, OnChanges {
message:any;
leaveStatus:any;
messages:any;
room:any;
roomName:any;
members:any;
loggedUserChat:any;
@Input() roomId:string;
@Output() closeAllDesktopComponents:EventEmitter<any> = new EventEmitter<any>();
@Output() showEmptyContainer:EventEmitter<any> = new EventEmitter<any>();
@@ -43,6 +44,7 @@ export class GroupMessagesPage implements OnInit, OnChanges {
private animationController: AnimationController,
private alertService: AlertService,
) {
this.loggedUserChat = authService.ValidatedUserChat['data'];
this.isGroupCreated = true;
}
ngOnChanges(changes: SimpleChanges): void {
@@ -50,10 +52,7 @@ export class GroupMessagesPage implements OnInit, OnChanges {
}
ngOnInit() {
this.authService.userData$.subscribe((res:any)=>{
this.loggedUser=res;
console.log(this.loggedUser);
});
this.loggedUser=this.loggedUserChat;
this.getRoomInfo();
console.log(this.roomId);
}
@@ -77,7 +76,7 @@ export class GroupMessagesPage implements OnInit, OnChanges {
get watch(){
this.getRoomInfo();
console.log('here watching');
return this.roomId;
}
getRoomInfo(){
@@ -112,18 +111,18 @@ export class GroupMessagesPage implements OnInit, OnChanges {
}
loadGroupMessages(room:any){
console.log('here'+room.t);
this.showLoader = true;
//If group is private call getGroupMembers
if(room.t === 'p'){
console.log('private');
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(res=>{
console.log(res);
let msgOnly = res['messages'].filter(data => data.t != 'au');
this.messages = msgOnly.reverse();
console.log(res);
this.showLoader = false;
});
}
@@ -138,14 +137,14 @@ export class GroupMessagesPage implements OnInit, OnChanges {
sendMessage(){
let body = {
"message":
{
"rid": this.roomId, "msg": this.message
"message":
{
"rid": this.roomId, "msg": this.message
}
}
this.chatService.sendMessage(body).subscribe(res=> {
/* this.loadGroupMessages(); */
/* this.loadGroupMessages(); */
this.getRoomInfo();
});
this.message = "";
@@ -174,7 +173,7 @@ export class GroupMessagesPage implements OnInit, OnChanges {
const leaveAnimation = (baseEl: any) => {
return enterAnimation(baseEl).direction('reverse');
}
/* const popover = await this.popoverController.create({
component: MessagesOptionsPage,
@@ -217,11 +216,11 @@ export class GroupMessagesPage implements OnInit, OnChanges {
else{
this.roomName = res.data.name.split('-').join(' ');
console.log(this.roomName);
this.getRoomInfo();
//this.modalController.dismiss();
};
});
}
@@ -252,9 +251,9 @@ export class GroupMessagesPage implements OnInit, OnChanges {
console.log(res);
if(res.data){
this.getRoomInfo();
//this.modalController.dismiss();
//this.modalController.dismiss();
};
});
}
async openChatOptions(ev: any) {
@@ -271,7 +270,7 @@ export class GroupMessagesPage implements OnInit, OnChanges {
}
async addContacts(){
console.log(this.members);
const modal = await this.modalController.create({
component: GroupContactsPage,
componentProps: {
@@ -279,7 +278,7 @@ export class GroupMessagesPage implements OnInit, OnChanges {
room: this.room,
members: this.members,
name: this.room.name,
},
},
cssClass: 'contacts',
backdropDismiss: false
});
@@ -310,7 +309,7 @@ export class GroupMessagesPage implements OnInit, OnChanges {
handler: () => {
console.log('Play clicked');
}
},
},
]
});
await actionSheet.present();