mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
refactore get user on chat
This commit is contained in:
@@ -8,6 +8,7 @@ import { ChatSystemService } from 'src/app/services/chat/chat-system.service'
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { ContactRepositoryService } from 'src/app/services/Repositorys/contacts/repository/contacts-repository.service';
|
||||
import { UserContacts } from 'src/app/services/Repositorys/contacts/data-source/contacts-data-source.service';
|
||||
import { RoomRepositoryService } from 'src/app/services/Repositorys/chat/repository/room-repository.service';
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +48,8 @@ export class ContactsPage implements OnInit {
|
||||
private chatService: ChatService,
|
||||
public ThemeService: ThemeService,
|
||||
public ChatSystemService: ChatSystemService,
|
||||
private contactsRepositoryService: ContactRepositoryService
|
||||
private contactsRepositoryService: ContactRepositoryService,
|
||||
private roomRepositoryService: RoomRepositoryService
|
||||
) {
|
||||
this.loggedUser = SessionStore.user.ChatData['data'];
|
||||
this.textSearch = "";
|
||||
@@ -71,11 +73,12 @@ export class ContactsPage implements OnInit {
|
||||
}
|
||||
|
||||
openMessagesPage(username: string) {
|
||||
if (window.innerWidth < 701) {
|
||||
this.createRoom(username);
|
||||
/* if (window.innerWidth < 701) {
|
||||
this.createRoom(username);
|
||||
}
|
||||
else {
|
||||
let body = {
|
||||
let body = {
|
||||
username: username,
|
||||
}
|
||||
|
||||
@@ -91,18 +94,27 @@ export class ContactsPage implements OnInit {
|
||||
|
||||
}, () => {
|
||||
this.loading = false
|
||||
});
|
||||
}
|
||||
});
|
||||
}*/
|
||||
}
|
||||
|
||||
async loadUsers() {
|
||||
/* this.ChatSystemService.getUser() */
|
||||
let users = await this.contactsRepositoryService.getUsers()
|
||||
if (users.isOk()) {
|
||||
this.originalUserList = users.value.data
|
||||
this.userList = [...this.originalUserList];
|
||||
this.userList.sort((a, b) => a.wxFullName.toLowerCase().localeCompare(b.wxFullName.toLowerCase()));
|
||||
console.log(users.value.data)
|
||||
try {
|
||||
let users = await this.contactsRepositoryService.getUsers();
|
||||
if (users.isOk()) {
|
||||
const userData = users.value.data.result;
|
||||
console.log(userData)
|
||||
this.originalUserList = userData;
|
||||
this.userList = [...this.originalUserList];
|
||||
this.userList.sort((a, b) => a.wxFullName.toLowerCase().localeCompare(b.wxFullName.toLowerCase()));
|
||||
console.log('User data loaded successfully:', this.originalUserList);
|
||||
} else {
|
||||
console.error('Failed to fetch users:', users.error);
|
||||
}
|
||||
this.loading = false;
|
||||
} catch (error) {
|
||||
console.error('Error loading users', error);
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,16 +150,21 @@ export class ContactsPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
createRoom(username: string) {
|
||||
async createRoom(username: string) {
|
||||
let body = {
|
||||
username: username,
|
||||
roomName: username,
|
||||
createdBy: SessionStore.user.UserId,
|
||||
roomType: 0,
|
||||
expirationDate: ""
|
||||
}
|
||||
this.chatService.createRoom(body).subscribe(res => {
|
||||
|
||||
this.room = res['room'];
|
||||
this.openMessagesModal(this.room._id);
|
||||
this.ChatSystemService.getAllRooms()
|
||||
});
|
||||
let room = await this.roomRepositoryService.create(body)
|
||||
console.log(room)
|
||||
/* this.chatService.createRoom(body).subscribe(res => {
|
||||
|
||||
this.room = res['room'];
|
||||
this.openMessagesModal(this.room._id);
|
||||
this.ChatSystemService.getAllRooms()
|
||||
}); */
|
||||
}
|
||||
|
||||
async openMessagesModal(roomId: any) {
|
||||
|
||||
Reference in New Issue
Block a user