mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
-add start direct message method from mobile App
- more improvements
This commit is contained in:
@@ -67,10 +67,10 @@ export class ChatPage implements OnInit {
|
||||
this.doRefresh();
|
||||
}
|
||||
doRefresh(){
|
||||
setInterval(()=>{
|
||||
//setInterval(()=>{
|
||||
this.getDirectMessages();
|
||||
this.getGroups();
|
||||
}, 2000);
|
||||
//}, 2000);
|
||||
}
|
||||
getGroups(){
|
||||
this.showLoader = true;
|
||||
@@ -88,7 +88,7 @@ export class ChatPage implements OnInit {
|
||||
|
||||
this.result = this.chatService.getAllDirectMessages().subscribe((res:any)=>{
|
||||
this.userDirectMessages = res.ims;
|
||||
console.log(this.userDirectMessages);
|
||||
console.log(res);
|
||||
|
||||
this.showLoader = false;
|
||||
});
|
||||
@@ -96,8 +96,8 @@ export class ChatPage implements OnInit {
|
||||
getChatMembers(){
|
||||
this.chatService.getMembers(this.userDirectMessages[0]._id).subscribe(res=> {
|
||||
this.dmUsers = res['members'].filter(data => data.username != this.loggedUser.me.username)
|
||||
console.log(res);
|
||||
console.log(this.dmUsers);
|
||||
/* console.log(res);
|
||||
console.log(this.dmUsers); */
|
||||
});
|
||||
}
|
||||
/* getConnectedChannels(){
|
||||
@@ -163,6 +163,8 @@ export class ChatPage implements OnInit {
|
||||
modal.onDidDismiss();
|
||||
}
|
||||
async openMessages(dm:any){
|
||||
console.log(dm);
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: MessagesPage,
|
||||
cssClass: 'group-messages',
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
</ion-toolbar>
|
||||
<ion-toolbar class="toolbar-search">
|
||||
<div class="search">
|
||||
<ion-searchbar (ionChange)="onChange($event)" placeholder="Pesquisar por cantacto" ></ion-searchbar>
|
||||
<ion-searchbar debounce="500" (ionChange)="onChange($event)" placeholder="Pesquisar por cantacto" ></ion-searchbar>
|
||||
</div>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
@@ -32,10 +32,10 @@
|
||||
<ion-label>{{header}}</ion-label>
|
||||
</div>
|
||||
|
||||
<div (click)="openMessages()" *virtualItem="let user" class="item-user">
|
||||
<div (click)="createRoom(user.username)" *virtualItem="let user" class="item-user">
|
||||
<p>{{user.name}}</p>
|
||||
<span class="icon">
|
||||
<ion-icon slot="end" name="ellipse"></ion-icon>
|
||||
<ion-icon class="{{user.status}}" slot="end" name="ellipse"></ion-icon>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -61,6 +61,8 @@
|
||||
border: 1px solid #ebebeb;
|
||||
margin: 5px 20px 5px 20px;
|
||||
border-radius: 5px;
|
||||
height: auto;
|
||||
padding: 0 !important;
|
||||
}
|
||||
.search ion-searchbar{
|
||||
/* border: 1px solid green; */
|
||||
@@ -69,7 +71,7 @@
|
||||
padding: 0 !important;
|
||||
--border-radius: 5px;
|
||||
--box-shadow: none;
|
||||
overflow: auto;
|
||||
overflow: hidden;
|
||||
--icon-color:#0d89d1;
|
||||
}
|
||||
|
||||
@@ -111,12 +113,24 @@
|
||||
}
|
||||
.item-user .icon{
|
||||
width: 10%;
|
||||
font-size: 10px;
|
||||
display: block;
|
||||
text-align: right;
|
||||
overflow: auto;
|
||||
}
|
||||
.icon ion-icon{
|
||||
font-size: 10px;
|
||||
color:#99e47b;
|
||||
}
|
||||
.online{
|
||||
color:#99e47b;
|
||||
}
|
||||
.offline{
|
||||
color:#cbced1;
|
||||
}
|
||||
.away{
|
||||
color:#ffd21f;
|
||||
}
|
||||
.invisible{
|
||||
color:#cbced1;
|
||||
}
|
||||
.busy{
|
||||
color:#f5455c;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ export class ContactsPage implements OnInit {
|
||||
options:any;
|
||||
contacts:any;
|
||||
textSearch:string;
|
||||
room:any;
|
||||
dm:any;
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
@@ -32,6 +34,8 @@ export class ContactsPage implements OnInit {
|
||||
this.loggedUser=res;
|
||||
});
|
||||
this.textSearch="";
|
||||
this.dm=null;
|
||||
this.room=null;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -46,10 +50,8 @@ export class ContactsPage implements OnInit {
|
||||
this.options = {
|
||||
headers: this.headers,
|
||||
};
|
||||
|
||||
this.chatService.getAllUsers().subscribe((res:any)=>{
|
||||
console.log(res.users);
|
||||
|
||||
this.contacts = res.users.filter(data => data.username != this.loggedUser.me.username);
|
||||
this.users = this.contacts.sort((a,b) => {
|
||||
if(a.name < b.name){
|
||||
@@ -60,11 +62,8 @@ export class ContactsPage implements OnInit {
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
this.showLoader = false;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
separateLetter(record, recordIndex, records){
|
||||
@@ -90,17 +89,65 @@ export class ContactsPage implements OnInit {
|
||||
|
||||
clicked(){
|
||||
console.log('clicked');
|
||||
|
||||
}
|
||||
async openMessages(){
|
||||
|
||||
createRoom(username:string){
|
||||
let body = {
|
||||
username: username,
|
||||
}
|
||||
this.chatService.createRoom(body).subscribe(res => {
|
||||
console.log(res);
|
||||
this.room = res['room'];
|
||||
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);
|
||||
this.dm = result[0];
|
||||
console.log(this.dm);
|
||||
this.openModal(this.dm);
|
||||
});
|
||||
}
|
||||
async openModal(dm:any){
|
||||
this.close();
|
||||
console.log(dm);
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: MessagesPage,
|
||||
cssClass: 'group-messages',
|
||||
backdropDismiss: false,
|
||||
componentProps: {
|
||||
dm: dm,
|
||||
},
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss();
|
||||
}
|
||||
|
||||
async openMessages(username:string){
|
||||
/* this.close(); */
|
||||
|
||||
let dm:any;
|
||||
//Create new room
|
||||
this.createRoom(username);
|
||||
//Get direct messages (dm)
|
||||
/* this.getDirectMessage(this.room._id); */
|
||||
console.log(this.dm);
|
||||
|
||||
|
||||
/* const modal = await this.modalController.create({
|
||||
component: MessagesPage,
|
||||
cssClass: 'group-messages',
|
||||
backdropDismiss: false,
|
||||
componentProps: {
|
||||
dm: dm,
|
||||
},
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss(); */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
||||
console.log(this.loggedUser);
|
||||
});
|
||||
|
||||
console.log(this.dm);
|
||||
/* console.log(this.dm); */
|
||||
|
||||
setInterval(()=>{
|
||||
//setInterval(()=>{
|
||||
this.checkUserPresence();
|
||||
this.loadMessages();
|
||||
}, 2000);
|
||||
//}, 2000);
|
||||
|
||||
this.getChatMembers();
|
||||
|
||||
@@ -93,7 +93,7 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
||||
|
||||
loadMessages(){
|
||||
this.chatService.getRoomMessages(this.dm._id).subscribe(res => {
|
||||
console.log(res);
|
||||
/* console.log(res); */
|
||||
this.messages = res['messages'].reverse();
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user