mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix direct room
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
|
||||
<ion-list class="header-bottom-contacts" *ngIf="roomMembers$ | async as memberList" >
|
||||
<ng-container *ngFor="let user of memberList; let i = index">
|
||||
<span *ngIf="roomType == RoomTypeEnum.Group"> {{ user.wxFullName }}<ng-container *ngIf="i < memberList.length - 1">, </ng-container> </span>
|
||||
<span > {{ user.wxFullName }}<ng-container *ngIf="i < memberList.length - 1">, </ng-container> </span>
|
||||
</ng-container>
|
||||
</ion-list>
|
||||
|
||||
|
||||
@@ -75,8 +75,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
@Input() _room!: RoomViewModel
|
||||
room!: RoomViewModel
|
||||
|
||||
@Input() roomId: string;
|
||||
@Input() showMessages: string;
|
||||
|
||||
@Output() openNewEventPage: EventEmitter<any> = new EventEmitter<any>();
|
||||
@Output() getDirectMessages: EventEmitter<any> = new EventEmitter<any>();
|
||||
@@ -142,6 +140,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
messageSendSubject: Subscription
|
||||
messageTypingSubject: Subscription
|
||||
messageOnReconnectSubject: Subscription
|
||||
messageOnSetRoomId: Subscription
|
||||
|
||||
messages1: {[key: string]: MessageViewModal[]} = {}
|
||||
MessageAttachmentFileType = MessageAttachmentFileType
|
||||
@@ -155,6 +154,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
date: {[key: string]: Object} = {}
|
||||
handleClickActive = true
|
||||
|
||||
|
||||
constructor(
|
||||
public popoverController: PopoverController,
|
||||
private modalController: ModalController,
|
||||
@@ -188,7 +188,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
|
||||
this.room = {...this._room} as any
|
||||
console.log('message', this.room)
|
||||
|
||||
if(this.room.local == IDBoolean.false) {
|
||||
this.getMessages()
|
||||
this.subscribeToChanges()
|
||||
@@ -204,6 +204,30 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
this.roomType = e.roomType;
|
||||
}
|
||||
})
|
||||
|
||||
this.messageOnSetRoomId?.unsubscribe()
|
||||
|
||||
if(this.room.local == IDBoolean.true) {
|
||||
this.messageOnSetRoomId = this.chatServiceService.roomDirectOnSetId({$roomId: this.room.$id}).subscribe((data) => {
|
||||
this.messageOnSetRoomId?.unsubscribe()
|
||||
|
||||
this.room = new RoomViewModel(data)
|
||||
|
||||
const hasMyMessage = this.messages1[this.room.$id].find(e => e.sender.wxUserId == SessionStore.user.UserId)
|
||||
|
||||
if(!hasMyMessage) {
|
||||
setTimeout(() => {
|
||||
this.getMessages()
|
||||
}, 500)
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
this.subscribeToChanges()
|
||||
}, 500)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
subscribeToChanges() {
|
||||
@@ -246,9 +270,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
|
||||
updateRoomDetails() {
|
||||
if(!this.room?.local) {
|
||||
this.chatServiceService.getRoomById(this.room.id)
|
||||
}
|
||||
this.chatServiceService.getRoomById(this.room.id)
|
||||
}
|
||||
|
||||
removeBold() {
|
||||
@@ -420,7 +442,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
memberId: SessionStore.user.UserId,
|
||||
messageId: message.id,
|
||||
requestId: '',
|
||||
roomId: this.room.$id
|
||||
roomId: this.room.id
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -506,8 +528,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
const index = this.messages1[this.room.$id].findIndex(e => e?.id === updateMessage.id); // Use triple equals for comparison
|
||||
|
||||
console.log('updateMessage', updateMessage)
|
||||
|
||||
if (index !== -1) { // Check if the item was found
|
||||
this.messages1[this.room.$id][index].info = updateMessage.info
|
||||
this.messages1[this.room.$id][index].message = updateMessage.message
|
||||
@@ -580,6 +600,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
sendTyping() {
|
||||
if(this.room.local == IDBoolean.false) {
|
||||
this.UserTypingRemoteRepositoryService.sendTyping(this.room.id)
|
||||
} else {
|
||||
console.log('dont send')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -768,8 +790,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
if(this.room.id) {
|
||||
message.roomId = this.room.id
|
||||
} else {
|
||||
message.roomId = this.room.$id
|
||||
}
|
||||
|
||||
message.sentAt = new Date().toISOString()
|
||||
@@ -792,7 +812,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
async messageResult(result: Promise<Result<MessageOutPutDataDTO, any>> ) {
|
||||
let message = await result
|
||||
|
||||
console.log('result', message)
|
||||
|
||||
if(message.isOk() && this.room.local == IDBoolean.true) {
|
||||
this.room.local = IDBoolean.false;
|
||||
|
||||
Reference in New Issue
Block a user