mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
create offline direct message
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user