improvements

This commit is contained in:
tiago.kayaya
2021-09-09 11:47:49 +01:00
parent 9ff7a588d8
commit 129a709570
5 changed files with 86 additions and 9 deletions
@@ -40,7 +40,7 @@
<ion-label>A conversa original mantêm-se como chat individual</ion-label>
</div>
<div *ngFor="let msg of messages; let last = last" >
<div *ngIf="msg.t != 'r' || msg.t != 'ul'" class='incoming-{{msg.u.username!=loggedUser.me.username}}'>
<div *ngIf="msg.t != 'r' || msg.t != 'ul' && msg.t != 'ru'" class='incoming-{{msg.u.username!=loggedUser.me.username}}'>
<div class="title">
<ion-label>{{msg.u.name}}</ion-label>
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
@@ -51,7 +51,24 @@
</div>
</div>
<div *ngIf="msg.t == 'r'" class="info-text">
<ion-label>Alterou o assunto para "{{msg.msg.split('-').join(' ')}}"</ion-label><br />
<ion-label>Alterou o nome do grupo para "{{msg.msg.split('-').join(' ')}}"</ion-label><br />
{{last ? scrollToBottom() : ''}}
</div>
<div *ngIf="msg.t == 'ul'" class="info-text-leave">
<div *ngFor="let user of allUsers">
<div *ngIf="msg.msg == user.username">
<ion-label>{{user.name}} saiu do grupo</ion-label><br />
</div>
</div>
{{last ? scrollToBottom() : ''}}
</div>
<div *ngIf="msg.t == 'ru'" class="info-text-leave">
<div *ngFor="let user of allUsers">
<div *ngIf="msg.msg == user.username">
<ion-label>{{user.name}} foi removido do grupo</ion-label><br />
</div>
</div>
{{last ? scrollToBottom() : ''}}
</div>
</div>
</div>
@@ -29,6 +29,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
roomName:any;
members:any;
contacts: string[] = [" Ana M.", "Andre F.", "Bruno G.", "Catarina T", "Tiago"];
allUsers:any[] = [];
roomId: string;
loggedUserChat:any;
@@ -70,6 +71,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.scrollToBottom();
this.serverLongPull();
this.setStatus('online');
this.getChatMembers();
}
setStatus(status:string){
@@ -125,6 +127,16 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
});
}
async getChatMembers(){
//return await this.chatService.getMembers(roomId).toPromise();
this.chatService.getAllUsers().subscribe(res=> {
console.log(res);
this.allUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username);
console.log(this.allUsers);
});
}
/* load(){
this.getGroupContacts();
this.loadGroupMessages();
@@ -39,7 +39,7 @@
<ion-label>A conversa original mantêm-se como chat individual</ion-label>
</div>
<div class="container-width-100" *ngFor="let msg of messages; let last = last" #scrollMe>
<div *ngIf="msg.t != 'r' && msg.t != 'ul'" class='incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45'>
<div *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'ru'" class='incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45'>
<div class="title">
<ion-label>{{msg.u.name}}</ion-label>
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
@@ -54,7 +54,19 @@
{{last ? scrollToBottom() : ''}}
</div>
<div *ngIf="msg.t == 'ul'" class="info-text-leave">
<ion-label>O contacto {{msg.msg.split('-').join(' ')}} saiu do grupo</ion-label><br />
<div *ngFor="let user of allUsers">
<div *ngIf="msg.msg == user.username">
<ion-label>{{user.name}} saiu do grupo</ion-label><br />
</div>
</div>
{{last ? scrollToBottom() : ''}}
</div>
<div *ngIf="msg.t == 'ru'" class="info-text-leave">
<div *ngFor="let user of allUsers">
<div *ngIf="msg.msg == user.username">
<ion-label>{{user.name}} foi removido do grupo</ion-label><br />
</div>
</div>
{{last ? scrollToBottom() : ''}}
</div>
</div>
@@ -24,6 +24,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
message:any;
leaveStatus:any;
messages:any;
allUsers:any[] = [];
room:any = new Array();
@@ -72,6 +73,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
this.serverLongPull();
console.log(this.roomId);
this.setStatus('online');
this.getChatMembers();
}
setStatus(status:string){
@@ -116,6 +118,16 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
window.removeEventListener('scroll', this.scrollChangeCallback, true);
}
async getChatMembers(){
//return await this.chatService.getMembers(roomId).toPromise();
this.chatService.getAllUsers().subscribe(res=> {
console.log(res);
this.allUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username);
console.log(this.allUsers);
});
}
openGroupContactsPage(){
this.openGroupContacts.emit(this.roomId);
}
@@ -210,7 +222,16 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
let body = {
"message":
{
"rid": this.roomId, "msg": this.message
"rid": this.roomId,
"msg": this.message,
"attachments": [{
"color": "#ff0000",
"text": "Yay for gruggy!",
"title": "Attachment Example",
"title_link": "https://youtube.com",
"title_link_download": false,
"image_url": "http://res.guggy.com/logo_128.png",
}]
}
}
@@ -52,8 +52,16 @@ export class ChatPopoverPage implements OnInit {
console.log(res);
this.close('leave');
},
(error)=>{
this.toastService.badRequest("Não foi possível sair do grupo")
(e)=>{
if(e.error.errorType = "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.close('cancel');
}
else{
this.toastService.badRequest("Não foi possível sair do grupo");
this.close('cancel');
}
},
()=>{
//loader.remove()
@@ -64,8 +72,15 @@ export class ChatPopoverPage implements OnInit {
console.log(res);
this.close('leave');
},
(error)=>{
this.toastService.badRequest("Não foi possível sair do grupo")
(e)=>{
if(e.error.errorType = "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.close('cancel');
}
else{
this.toastService.badRequest("Não foi possível sair do grupo");
this.close('cancel');
}
},
()=>{
//loader.remove()