mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix last message
This commit is contained in:
@@ -41,7 +41,7 @@ import { UserTypingRemoteRepositoryService } from 'src/app/module/chat/data/repo
|
||||
import { MessageLocalDataSourceService } from 'src/app/module/chat/data/repository/message/message-local-data-source.service';
|
||||
import { RoomType } from "src/app/core/chat/entity/group";
|
||||
import { Logger } from 'src/app/services/logger/main/service';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { AlertController } from '@ionic/angular';
|
||||
import { ViewOncesImagePage, ViewOncesImagePageInput } from '../../modal/view-onces/view-onces.page';
|
||||
import { MemberTable } from 'src/app/infra/database/dexie/instance/chat/schema/members';
|
||||
@@ -50,8 +50,6 @@ import { RoomTable } from 'src/app/infra/database/dexie/instance/chat/schema/roo
|
||||
import { TypingTable } from 'src/app/infra/database/dexie/instance/chat/schema/typing';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { RoomViewModel } from '../../store/model/room';
|
||||
|
||||
@Component({
|
||||
selector: 'app-messages',
|
||||
templateUrl: './messages.page.html',
|
||||
@@ -114,7 +112,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
@ViewChild('array') myInputRef!: ElementRef;
|
||||
|
||||
userName = "";
|
||||
@Input() room!: RoomViewModel;
|
||||
room: any = new Array();
|
||||
roomName: any;
|
||||
isAdmin = true;
|
||||
roomCountDownDate: string;
|
||||
@@ -137,7 +135,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
messages: MessageEntity[] = []
|
||||
|
||||
RoomDataSubject: Subscription
|
||||
messageReceiveSubject: Subscription
|
||||
messageDeleteSubject: Subscription
|
||||
messageUpdateSubject: Subscription
|
||||
@@ -182,7 +179,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
private UserTypingRemoteRepositoryService: UserTypingRemoteRepositoryService,
|
||||
private messageLocalDataSourceService: MessageLocalDataSourceService,
|
||||
private alertController: AlertController,
|
||||
private http: HttpClient,
|
||||
private http: HttpClient
|
||||
) {
|
||||
// update
|
||||
this.checkAudioPermission()
|
||||
@@ -229,6 +226,17 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
|
||||
|
||||
this.roomData$ = this.RoomLocalRepository.getRoomByIdLive(this.roomId)
|
||||
|
||||
this.roomData$.subscribe(e => {
|
||||
// console.log(e)
|
||||
if(e) {
|
||||
this.roomType = e.roomType
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
this.getMessages();
|
||||
this.listenToIncomingMessage();
|
||||
this.listenToDeleteMessage();
|
||||
@@ -249,7 +257,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
)
|
||||
|
||||
this.roomStatus$ = this.MemberListLocalRepository.allMemberOnline(this.roomId)
|
||||
this.chatServiceService.getRoomById(this.roomId)
|
||||
// this.chatServiceService.getRoomById(this.roomId)
|
||||
|
||||
this.messageTypingSubject?.unsubscribe()
|
||||
this.messageTypingSubject = this.userTypingLocalRepository.getUserTypingLiveByRoomId(this.roomId).subscribe((e) => {
|
||||
@@ -268,15 +276,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
|
||||
this.chatServiceService.removeBoldFromRoom({roomId: this.roomId})
|
||||
|
||||
// this.RoomDataSubject?.unsubscribe()
|
||||
// this.RoomDataSubject = this.RoomLocalRepository.getRoomByIdLive(this.roomId).pipe(
|
||||
// map((roomData) => new RoomViewModel(roomData)),
|
||||
// tap((room: RoomViewModel) => {
|
||||
// this.room = room
|
||||
// })
|
||||
// ).subscribe()
|
||||
|
||||
}
|
||||
|
||||
messageStatus(message: MessageEntity) {
|
||||
@@ -470,6 +469,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
this.messageSendSubject = this.chatServiceService.listenToSendMessage(this.roomId).subscribe((updateMessage) => {
|
||||
|
||||
|
||||
const index = this.messages1[this.roomId].findIndex(e => e?.requestId === updateMessage.requestId); // Use triple equals for comparison
|
||||
|
||||
if (index !== -1) { // Check if the item was found
|
||||
@@ -733,7 +733,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
safeFile: this.sanitiser.bypassSecurityTrustResourceUrl(this.audioRecordedDataUrl)
|
||||
}]
|
||||
|
||||
this.chatServiceService.sendMessage(message, this.room.roomType)
|
||||
this.chatServiceService.sendMessage(message, this.roomType)
|
||||
this.messages1[this.roomId].push(message)
|
||||
setTimeout(() => {
|
||||
this.scrollToBottomClicked()
|
||||
@@ -794,7 +794,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
setTimeout(() => {
|
||||
this.scrollToBottomClicked()
|
||||
}, 100)
|
||||
const data = await this.chatServiceService.sendMessage(message, this.room.roomType)
|
||||
const data = await this.chatServiceService.sendMessage(message, this.roomType)
|
||||
|
||||
}
|
||||
|
||||
@@ -898,7 +898,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
roomId: this.roomId,
|
||||
members: [],
|
||||
isAdmin: this.isAdmin,
|
||||
roomType: this.room.roomType
|
||||
roomType: this.roomType
|
||||
}
|
||||
});
|
||||
await modal.present();
|
||||
@@ -980,7 +980,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
setTimeout(() => {
|
||||
this.scrollToBottomClicked()
|
||||
}, 100)
|
||||
this.chatServiceService.sendMessage(message, this.room.roomType)
|
||||
this.chatServiceService.sendMessage(message, this.roomType)
|
||||
|
||||
}
|
||||
|
||||
@@ -1036,7 +1036,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
setTimeout(() => {
|
||||
this.scrollToBottomClicked()
|
||||
}, 100)
|
||||
this.chatServiceService.sendMessage(message, this.room.roomType)
|
||||
this.chatServiceService.sendMessage(message, this.roomType)
|
||||
this.textField = ''
|
||||
|
||||
}
|
||||
@@ -1126,7 +1126,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
setTimeout(() => {
|
||||
this.scrollToBottomClicked()
|
||||
}, 100)
|
||||
this.chatServiceService.sendMessage(message, this.room.roomType)
|
||||
this.chatServiceService.sendMessage(message, this.roomType)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1182,7 +1182,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
setTimeout(() => {
|
||||
this.scrollToBottomClicked()
|
||||
}, 100)
|
||||
this.chatServiceService.sendMessage(message, this.room.roomType)
|
||||
this.chatServiceService.sendMessage(message, this.roomType)
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user