From 3c716ee3eaa05e9dc85bc8f5e5e8772ad9f0791c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Sun, 12 Jun 2022 23:43:18 +0100 Subject: [PATCH] verification added on group option --- .../group-messages/group-messages.page.ts | 155 +++++++++--------- 1 file changed, 81 insertions(+), 74 deletions(-) diff --git a/src/app/shared/chat/group-messages/group-messages.page.ts b/src/app/shared/chat/group-messages/group-messages.page.ts index aef5acf91..7b4e79ba8 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.ts +++ b/src/app/shared/chat/group-messages/group-messages.page.ts @@ -101,6 +101,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe audioPermissionStatus: 'granted'| 'denied' | 'prompt' | null = null sessionStore = SessionStore + groupAdminId = ""; constructor( public wsChatMethodsService: WsChatMethodsService, @@ -164,7 +165,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe console.log(this.roomId) this.loggedUser = this.loggedUserChat; //setTimeout(() => { - this.getRoomInfo(); + this.getRoomInfo() //}, 1000); this.getChatMembers(); //this.getMessageDB(); @@ -401,7 +402,9 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe async getRoomInfo() { this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory({}); let room = await this.chatService.getRoomInfo(this.roomId).toPromise(); + console.log('ROOM',room) this.room = room['room']; + this.groupAdminId = this.room.u._id; if (this.room.name) { this.roomName = this.room.name.split('-').join(' '); } @@ -503,82 +506,86 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe } async openGroupMessagesOptions() { - - const enterAnimation = (baseEl: any) => { - const backdropAnimation = this.animationController.create() - .addElement(baseEl.querySelector('ion-backdrop')!) - .fromTo('opacity', '0.01', 'var(--backdrop-opacity)'); - - const wrapperAnimation = this.animationController.create() - .addElement(baseEl.querySelector('.modal-wrapper')!) - .keyframes([ - { offset: 0, opacity: '1', right: '-100%' }, - { offset: 1, opacity: '1', right: '0px' } - ]); - - return this.animationController.create() - .addElement(baseEl) - .easing('ease-out') - .duration(500) - .addAnimation([backdropAnimation, wrapperAnimation]); + alert(this.groupAdminId) + if(SessionStore.user.ChatData.data.userId == this.groupAdminId) { + const enterAnimation = (baseEl: any) => { + const backdropAnimation = this.animationController.create() + .addElement(baseEl.querySelector('ion-backdrop')!) + .fromTo('opacity', '0.01', 'var(--backdrop-opacity)'); + + const wrapperAnimation = this.animationController.create() + .addElement(baseEl.querySelector('.modal-wrapper')!) + .keyframes([ + { offset: 0, opacity: '1', right: '-100%' }, + { offset: 1, opacity: '1', right: '0px' } + ]); + + return this.animationController.create() + .addElement(baseEl) + .easing('ease-out') + .duration(500) + .addAnimation([backdropAnimation, wrapperAnimation]); + } + + const leaveAnimation = (baseEl: any) => { + return enterAnimation(baseEl).direction('reverse'); + } + + + /* const popover = await this.popoverController.create({ + component: MessagesOptionsPage, + componentProps: { + roomId: this.dm._id, + }, + cssClass: 'messages-options', + event: ev, + translucent: true, + }); + return await popover.present(); */ + + + + + const modal = await this.modalController.create({ + enterAnimation, + leaveAnimation, + component: ChatPopoverPage, + cssClass: 'model profile-modal search-submodal', + componentProps: { + roomId: this.roomId, + members: this.members, + } + }); + await modal.present(); + modal.onDidDismiss().then(res => { + + if (res.data == 'leave') { + this.getRoomInfo(); + this.closeAllDesktopComponents.emit(); + this.showEmptyContainer.emit(); + this.wsChatMethodsService.hidingRoom(this.roomId); + } + else if (res.data == 'delete') { + this.closeAllDesktopComponents.emit(); + this.showEmptyContainer.emit(); + } + else if (res.data == 'cancel') { + + } + else if (res.data == 'edit') { + + //this.closeAllDesktopComponents.emit(); + this.openEditGroupPage.emit(this.roomId); + } + else { + this.roomName = res.data.name.split('-').join(' '); + + }; + + }); } - const leaveAnimation = (baseEl: any) => { - return enterAnimation(baseEl).direction('reverse'); - } - - - /* const popover = await this.popoverController.create({ - component: MessagesOptionsPage, - componentProps: { - roomId: this.dm._id, - }, - cssClass: 'messages-options', - event: ev, - translucent: true, - }); - return await popover.present(); */ - - - - const modal = await this.modalController.create({ - enterAnimation, - leaveAnimation, - component: ChatPopoverPage, - cssClass: 'model profile-modal search-submodal', - componentProps: { - roomId: this.roomId, - members: this.members, - } - }); - await modal.present(); - modal.onDidDismiss().then(res => { - - if (res.data == 'leave') { - this.getRoomInfo(); - this.closeAllDesktopComponents.emit(); - this.showEmptyContainer.emit(); - this.wsChatMethodsService.hidingRoom(this.roomId); - } - else if (res.data == 'delete') { - this.closeAllDesktopComponents.emit(); - this.showEmptyContainer.emit(); - } - else if (res.data == 'cancel') { - - } - else if (res.data == 'edit') { - - //this.closeAllDesktopComponents.emit(); - this.openEditGroupPage.emit(this.roomId); - } - else { - this.roomName = res.data.name.split('-').join(' '); - - }; - - }); } openSendGroupMessageOptions(ev?: any) {