commet all chat method and fix create direct message

This commit is contained in:
Peter Maquiran
2024-06-12 00:25:37 +01:00
parent 39bc8979a8
commit 703c3aaed6
5 changed files with 80 additions and 82 deletions
@@ -36,7 +36,7 @@
<ion-label>{{ header }}</ion-label>
</div>
<div (click)="openMessagesPage(user.wxFullName)" *virtualItem="let user" class="item-user cursor-pointer">
<div (click)="openMessagesPage(user.wxFullName, user.wxUserId)" *virtualItem="let user" class="item-user cursor-pointer">
<p>{{ user.wxFullName }}</p>
<span class="icon">
<ion-icon [class]="user.status" slot="end" name="ellipse"></ion-icon>
@@ -10,7 +10,8 @@ import { ContactRepositoryService } from 'src/app/services/Repositorys/contacts/
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';
import { HttpErrorResponse } from '@angular/common/http';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { ToastService } from 'src/app/services/toast.service';
class UserToSelect {
@@ -45,11 +46,12 @@ export class ContactsPage implements OnInit {
constructor(
private modalController: ModalController,
private chatService: ChatService,
public ThemeService: ThemeService,
public ChatSystemService: ChatSystemService,
private contactsRepositoryService: ContactRepositoryService,
private roomRepositoryService: RoomRepositoryService
private roomRepositoryService: RoomRepositoryService,
private httpErrorHandle: HttpErrorHandle,
private toastService: ToastService,
) {
this.loggedUser = SessionStore.user.ChatData['data'];
this.textSearch = "";
@@ -72,8 +74,8 @@ export class ContactsPage implements OnInit {
this.userList.sort((a, b) => a.wxFullName.toLowerCase().localeCompare(b.wxFullName.toLowerCase()));
}
openMessagesPage(username: string) {
this.createRoom(username);
openMessagesPage(username: string, wxUserId: number) {
this.createRoom(username, wxUserId);
/* if (window.innerWidth < 701) {
this.createRoom(username);
}
@@ -150,12 +152,13 @@ export class ContactsPage implements OnInit {
}
async createRoom(username: string) {
async createRoom(username: string, wxUserId: number) {
const result = await this.roomRepositoryService.create({
roomName: username,
createdBy: SessionStore.user.UserId,
roomType: 0,
expirationDate: null
expirationDate: null,
members: [wxUserId]
})
@@ -163,10 +166,13 @@ export class ContactsPage implements OnInit {
if(result.isOk()) {
// this.addGroupMessage.emit(result);
this.openMessage.emit(result.value.data.id);
} else if(result.error instanceof HttpErrorResponse) {
this.httpErrorHandle.httpStatusHandle(result.error)
} else {
this.toastService._badRequest("Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.")
console.log(result.error)
}
/* this.chatService.createRoom(body).subscribe(res => {
@@ -192,13 +198,5 @@ export class ContactsPage implements OnInit {
await modal.present();
}
async openMessages(username: string) {
/* this.close(); */
let dm: any;
//Create new room
this.createRoom(username);
}
}