-
{{user.first}} {{user.last}}
+
{{user.name}}
diff --git a/src/app/pages/chat/messages/contacts/contacts.page.ts b/src/app/pages/chat/messages/contacts/contacts.page.ts
index dc2c1c7a4..dfae3aab5 100644
--- a/src/app/pages/chat/messages/contacts/contacts.page.ts
+++ b/src/app/pages/chat/messages/contacts/contacts.page.ts
@@ -1,6 +1,8 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { ModalController } from '@ionic/angular';
+import { AuthService } from 'src/app/services/auth.service';
+import { ChatService } from 'src/app/services/chat.service';
import { GroupMessagesPage } from '../../group-messages/group-messages.page';
import { MessagesPage } from '../messages.page';
@@ -11,77 +13,67 @@ import { MessagesPage } from '../messages.page';
})
export class ContactsPage implements OnInit {
showLoader: boolean;
+ loggedUser: any;
users = [];
headers: HttpHeaders;
options:any;
-
- contacts: Contact[] = [
- {
- first: 'Ana',
- last: 'Manuel',
- url: 'https://randomuser.me/api/portraits/med/women/54.jpg',
- },
- {
- first: 'Abdullah',
- last: 'Hill',
- url: 'https://randomuser.me/api/portraits/med/women/54.jpg',
- },
- {
- first: 'Batur',
- last: 'Oymen',
- url: 'https://randomuser.me/api/portraits/med/women/54.jpg',
- },
- {
- first: 'Bianca',
- last: 'Costa',
- url: 'https://randomuser.me/api/portraits/med/women/54.jpg',
- },
- {
- first: 'Zaya',
- last: 'Mary',
- url: 'https://randomuser.me/api/portraits/med/women/54.jpg',
- },
- {
- first: 'Tiago',
- last: 'Kayaya',
- url: 'https://randomuser.me/api/portraits/med/women/54.jpg',
- }
-];
+ contacts:any;
+ textSearch:string;
constructor(
private modalController: ModalController,
private http: HttpClient,
+ private chatService: ChatService,
+ private authService: AuthService,
)
- { }
+ {
+ this.authService.userData$.subscribe((res:any)=>{
+ this.loggedUser=res;
+ });
+ this.textSearch="";
+ }
ngOnInit() {
this.loadUsers();
}
+ onChange(event){
+ this.textSearch = event.detail.value;
+ }
loadUsers(){
this.options = {
headers: this.headers,
};
- this.users = this.contacts.sort((a,b) => {
- if(a.first < b.first){
- return -1;
- }
- if(a.first > b.first){
- return 1;
- }
- return 0;
+
+ 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){
+ return -1;
+ }
+ if(a.name > b.name){
+ return 1;
+ }
+ return 0;
+ });
+
+ this.showLoader = false;
});
+
+
}
separateLetter(record, recordIndex, records){
if(recordIndex == 0){
- return record.first[0];
+ return record.name[0];
}
- let first_prev = records[recordIndex - 1].first[0];
- let first_current = record.first[0];
+ let first_prev = records[recordIndex - 1].name[0];
+ let first_current = record.name[0];
if(first_prev != first_current){
return first_current;
@@ -95,9 +87,7 @@ export class ContactsPage implements OnInit {
close(){
this.modalController.dismiss();
}
- onChange(event){
-
- }
+
clicked(){
console.log('clicked');
diff --git a/src/app/pipes/filter.pipe.spec.ts b/src/app/pipes/filter.pipe.spec.ts
new file mode 100644
index 000000000..1427de361
--- /dev/null
+++ b/src/app/pipes/filter.pipe.spec.ts
@@ -0,0 +1,8 @@
+import { FilterPipe } from './filter.pipe';
+
+describe('FilterPipe', () => {
+ it('create an instance', () => {
+ const pipe = new FilterPipe();
+ expect(pipe).toBeTruthy();
+ });
+});
diff --git a/src/app/pipes/filter.pipe.ts b/src/app/pipes/filter.pipe.ts
new file mode 100644
index 000000000..a6a6398c9
--- /dev/null
+++ b/src/app/pipes/filter.pipe.ts
@@ -0,0 +1,21 @@
+import { Pipe, PipeTransform } from '@angular/core';
+
+@Pipe({
+ name: 'filter'
+})
+export class FilterPipe implements PipeTransform {
+
+ transform(contatcs: any[], text:string, column:string): any {
+
+ if(text === ''){
+ return contatcs;
+ }
+
+ text = text.toLowerCase();
+
+ return contatcs.filter(item =>{
+ return item[column].toLowerCase().includes(text);
+ });
+ }
+
+}
diff --git a/src/app/pipes/pipes.module.ts b/src/app/pipes/pipes.module.ts
new file mode 100644
index 000000000..0d9ad52be
--- /dev/null
+++ b/src/app/pipes/pipes.module.ts
@@ -0,0 +1,10 @@
+import { NgModule } from '@angular/core';
+import { FilterPipe } from './filter.pipe';
+
+
+@NgModule({
+ declarations: [FilterPipe],
+ exports: [FilterPipe],
+ imports: []
+})
+export class PipesModule { }