mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
save
This commit is contained in:
@@ -28,11 +28,10 @@ export class ContactsPage implements OnInit {
|
||||
private http: HttpClient,
|
||||
private chatService: ChatService,
|
||||
private authService: AuthService,
|
||||
)
|
||||
{
|
||||
this.authService.userData$.subscribe((res:any)=>{
|
||||
this.loggedUser=res;
|
||||
});
|
||||
)
|
||||
{
|
||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||
|
||||
this.textSearch="";
|
||||
this.dm=null;
|
||||
this.room=null;
|
||||
@@ -47,7 +46,7 @@ export class ContactsPage implements OnInit {
|
||||
}
|
||||
|
||||
loadUsers(){
|
||||
this.options = {
|
||||
this.options = {
|
||||
headers: this.headers,
|
||||
};
|
||||
this.chatService.getAllUsers().subscribe((res:any)=>{
|
||||
@@ -86,7 +85,7 @@ export class ContactsPage implements OnInit {
|
||||
close(){
|
||||
this.modalController.dismiss();
|
||||
}
|
||||
|
||||
|
||||
clicked(){
|
||||
console.log('clicked');
|
||||
}
|
||||
@@ -99,17 +98,17 @@ export class ContactsPage implements OnInit {
|
||||
console.log(res);
|
||||
this.room = res['room'];
|
||||
console.log(this.room._id);
|
||||
|
||||
|
||||
this.getDirectMessage(this.room._id);
|
||||
});
|
||||
}
|
||||
getDirectMessage(roomId:any){
|
||||
console.log(roomId);
|
||||
|
||||
|
||||
this.chatService.getAllDirectMessages().subscribe(res=>{
|
||||
let result = res['ims'].filter(data => data._id == roomId);
|
||||
console.log(result[0]);
|
||||
|
||||
|
||||
this.dm = result[0];
|
||||
console.log(this.dm);
|
||||
this.openModal(this.dm._id);
|
||||
@@ -118,7 +117,7 @@ export class ContactsPage implements OnInit {
|
||||
async openModal(roomId:any){
|
||||
this.close();
|
||||
console.log(roomId);
|
||||
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: MessagesPage,
|
||||
cssClass: 'group-messages',
|
||||
@@ -139,8 +138,8 @@ export class ContactsPage implements OnInit {
|
||||
//Get direct messages (dm)
|
||||
/* this.getDirectMessage(this.room._id); */
|
||||
console.log(this.dm);
|
||||
|
||||
|
||||
|
||||
|
||||
/* const modal = await this.modalController.create({
|
||||
component: MessagesPage,
|
||||
cssClass: 'group-messages',
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<button class="btn-no-color" (click)="openMessagesOptions()">
|
||||
<ion-icon src="assets/images/icons-menu.svg"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div hidden class="header-bottom" (click)="addContacts()">
|
||||
<div class="header-bottom-icon">
|
||||
@@ -35,7 +35,7 @@
|
||||
<ion-refresher-content>
|
||||
</ion-refresher-content>
|
||||
</ion-refresher>
|
||||
<div class="messages" #scrollMe>
|
||||
<div id="scrollToBottom" class="messages" #scrollMe>
|
||||
<div *ngFor="let msg of messages" class='incoming-{{msg.u.username!=loggedUser.me.username}}'>
|
||||
<div class="title">
|
||||
<ion-label>{{msg.u.name}}</ion-label>
|
||||
@@ -83,7 +83,7 @@
|
||||
<ion-item class="ion-no-padding ion-no-margin type-message" lines="none">
|
||||
<ion-textarea clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
|
||||
<button class="btn-no-color" (click)="notImplemented()">
|
||||
<ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
|
||||
<!-- <ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon> -->
|
||||
</button>
|
||||
</ion-item>
|
||||
</div>
|
||||
@@ -96,4 +96,4 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</ion-footer>
|
||||
</ion-footer>
|
||||
|
||||
@@ -26,8 +26,9 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
||||
userPresence='';
|
||||
dmUsers:any;
|
||||
roomId:string;
|
||||
el:any;
|
||||
|
||||
|
||||
|
||||
constructor(
|
||||
public popoverController: PopoverController,
|
||||
private modalController: ModalController,
|
||||
@@ -36,7 +37,8 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
||||
private authService: AuthService,
|
||||
private alertService: AlertService,
|
||||
private toastService: ToastService,
|
||||
) {
|
||||
) {
|
||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||
this.roomId = this.navParams.get('roomId');
|
||||
}
|
||||
|
||||
@@ -44,15 +46,12 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
||||
|
||||
this.scrollToBottom();
|
||||
|
||||
this.authService.userData$.subscribe((res:any)=>{
|
||||
this.loggedUser=res;
|
||||
console.log(this.loggedUser);
|
||||
});
|
||||
|
||||
/* setInterval(()=>{ */
|
||||
this.load();
|
||||
/* }, 9000); */
|
||||
|
||||
this.el = document.getElementById("scrollToBottom");
|
||||
this.el.scrollTop = this.el.scrollHeight - this.el.scrollTop;
|
||||
|
||||
}
|
||||
|
||||
notImplemented(){
|
||||
@@ -70,34 +69,31 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
||||
this.load();
|
||||
ev.target.complete();
|
||||
}
|
||||
|
||||
ngAfterViewChecked() {
|
||||
this.scrollToBottom();
|
||||
}
|
||||
scrollToBottom(): void {
|
||||
|
||||
ngAfterViewChecked() {
|
||||
this.scrollToBottom();
|
||||
}
|
||||
|
||||
scrollToBottom(): void {
|
||||
try {
|
||||
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
||||
} catch(err) { }
|
||||
|
||||
}
|
||||
loadMoreMessages(ev:any){
|
||||
} catch(err) { }
|
||||
|
||||
}
|
||||
|
||||
sendMessage(){
|
||||
let body = {
|
||||
"message":
|
||||
{
|
||||
"rid": this.roomId, "msg": this.message
|
||||
"message":
|
||||
{
|
||||
"rid": this.roomId, "msg": this.message
|
||||
}
|
||||
}
|
||||
this.chatService.sendMessage(body).subscribe(res=> {
|
||||
this.loadMessages();
|
||||
this.loadMessages();
|
||||
});
|
||||
this.message = "";
|
||||
}
|
||||
|
||||
|
||||
loadMessages(){
|
||||
this.showLoader = true;
|
||||
this.chatService.getRoomMessages(this.roomId).subscribe(res => {
|
||||
@@ -133,7 +129,7 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
||||
async addContacts(){
|
||||
const modal = await this.modalController.create({
|
||||
component: ContactsPage,
|
||||
componentProps: {},
|
||||
componentProps: {},
|
||||
cssClass: 'contacts',
|
||||
backdropDismiss: false
|
||||
});
|
||||
@@ -153,4 +149,4 @@ async openChatOptions(ev?: any) {
|
||||
return await popover.present();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user