create offline direct message

This commit is contained in:
Peter Maquiran
2024-09-17 16:02:12 +01:00
parent 9be19bfc78
commit 1bc5707321
266 changed files with 860 additions and 2771 deletions
@@ -11,6 +11,7 @@ import { SessionStore } from 'src/app/store/session.service';
import { MessageEntity } from 'src/app/core/chat/entity/message';
// import { ChatSystemService } from 'src/app/services/chat/chat-system.service'
import { RoomType } from "src/app/core/chat/entity/group";
import { RoomViewModel } from '../../store/model/room';
@Component({
selector: 'app-contacts',
@@ -30,6 +31,7 @@ export class ContactsPage implements OnInit {
@Output() emptyTextDescriptionOpen: EventEmitter<any> = new EventEmitter<any>();
@Output() backToChat: EventEmitter<any> = new EventEmitter<any>();
@Output() closeAllDesktopComponents: EventEmitter<any> = new EventEmitter<any>();
@Output() openMessagesToStartDirectConversation = new EventEmitter<RoomViewModel>();
@Input() roomId: string;
@@ -39,7 +41,7 @@ export class ContactsPage implements OnInit {
private contactsRepositoryService: ContactRepositoryService,
private httpErrorHandle: HttpErrorHandle,
private toastService: ToastService,
private chatServiceService: ChatServiceService
private chatServiceService: ChatServiceService,
)
{}
@@ -51,11 +53,12 @@ export class ContactsPage implements OnInit {
async loadUsers() {
this.loading = true
const getallChatUsers = await this.contactsRepositoryService.getUsers()
const getallChatUsers = await this.chatServiceService.getContactList()
if(getallChatUsers.isOk()) {
this.allChatUsers = getallChatUsers.value.data.result.sort((a,b) => {
this.allChatUsers = getallChatUsers.value.sort((a,b) => {
if(a.wxFullName < b.wxFullName) {
return -1;
}
@@ -111,14 +114,19 @@ export class ContactsPage implements OnInit {
doRefresh(event){
}
close(roomId) {
close(roomId?: string) {
if (roomId) {
this.backToChat.emit({ roomId: roomId });
this.backToChat.emit( roomId );
} else {
this.closeAllDesktopComponents.emit();
}
}
openMessageComponent(room: RoomViewModel) {
this.openMessagesToStartDirectConversation.emit(room)
}
onChange(event) {
const textSearch = event.detail.value;
@@ -155,29 +163,34 @@ export class ContactsPage implements OnInit {
selectOnce = true
async select(user: UserContacts) {
const message = new MessageEntity();
// const result = await this.chatServiceService.sendMessage(message, RoomType.Direct)
message.sender = {
userPhoto: '',
wxeMail: SessionStore.user.Email,
wxFullName: SessionStore.user.FullName,
wxUserId: SessionStore.user.UserId
}
message.receiverId = user.wxUserId
message.message = null
const result = await this.chatServiceService.sendMessage(message, RoomType.Direct)
console.log('result', result);
const result = await this.chatServiceService.roomCreateLocalDirectMessage({
roomName: user.wxFullName,
receiverId: user.wxUserId,
});
if(result.isOk()) {
await this.chatServiceService.getRoomById(result.value.roomId)
this.close(result.value.roomId)
const room = await this.chatServiceService.roomGetLocalById({
$roomId: result.value
})
if(room.isOk()) {
console.log('room', room)
console.log('result.value', result.value)
console.log('receiverId', user.wxUserId)
// await this.chatServiceService.getRoomById(user.wxUserId.toString())
this.close(user.wxUserId.toString())
this.openMessageComponent(new RoomViewModel(room.value))
}
} else {
console.log(result.error)
this.close(user.wxUserId.toString())
}
}
}