improve chat

This commit is contained in:
Peter Maquiran
2022-10-04 11:33:46 +01:00
parent b3dfb396f3
commit e738bf08f3
14 changed files with 74 additions and 144 deletions
@@ -1,8 +1,8 @@
import { HttpHeaders } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { GroupMessagesPage } from '../../group-messages/group-messages.page';
import { ThemeService } from 'src/app/services/theme.service'
import { ChatSystemService } from 'src/app/services/chat/chat-system.service'
@Component({
selector: 'app-contacts',
@@ -10,58 +10,15 @@ import { ThemeService } from 'src/app/services/theme.service'
styleUrls: ['./contacts.page.scss'],
})
export class ContactsPage implements OnInit {
showLoader: boolean;
users = [];
contact: string[] = [" Ana M.", "Andre F.", "Bruno G.", "Catarina T", "Tiago"];
headers: HttpHeaders;
options:any;
contacts = [
{
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',
}
];
constructor(
private modalController: ModalController,
public ThemeService: ThemeService
public ThemeService: ThemeService,
public ChatSystemService: ChatSystemService
)
{
this.headers = new HttpHeaders();
this.headers = this.headers.set('Access-Control-Allow-Origin' , '*');
this.headers = this.headers.set('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT');
this.headers = this.headers.set('Accept','application/json');
this.headers = this.headers.set('content-type','application/json');
}
ngOnInit() {
@@ -70,46 +27,11 @@ export class ContactsPage implements OnInit {
}
loadUsers(){
this.options = {
headers: this.headers,
};
/* this.http.get('https://randomuser.me/api/?results=100', this.options)
.subscribe(res => {
this.users = res['results'].sort((a,b) => {
if(a.name.first < b.name.first){
return -1;
}
if(a.name.first > b.name.first){
return 1;
}
return 0;
});
}); */
this.users = this.contacts.sort((a,b) => {
if(a.first < b.first){
return -1;
}
if(a.first > b.first){
return 1;
}
return 0;
});
this.ChatSystemService.getUser()
}
separateLetter(record, recordIndex, records){
/* if(recordIndex == 0){
return record.name.first[0];
}
let first_prev = records[recordIndex - 1].name.first[0];
let first_current = record.name.first[0];
if(first_prev != first_current){
return first_current;
}
return null; */
if(recordIndex == 0){
return record.first[0];
}