remove duplicate

This commit is contained in:
Peter Maquiran
2024-09-01 12:57:33 +01:00
parent 6193aac4a8
commit 41c63b6c56
33 changed files with 359 additions and 323 deletions
-4
View File
@@ -36,10 +36,6 @@ const routes: Routes = [
path: 'chat-message-debugging',
loadChildren: () => import('./modal/chat-message-debugging/chat-message-debugging.module').then( m => m.ChatMessageDebuggingPageModule)
},
{
path: 'add-user',
loadChildren: () => import('./component/add-user/add-user.module').then( m => m.AddUserPageModule)
},
{
path: 'empty-chat',
loadChildren: () => import('./component/empty-chat/empty-chat.module').then( m => m.EmptyChatPageModule)
+55 -88
View File
@@ -39,94 +39,60 @@
</ion-segment>
</ion-toolbar>
<!-- <div *ngFor="let room of roomsWithLastMessages">
{{ room.name }} == {{ room.lastMessage.message }}
</div> -->
<div class=" aside overflow-y-auto d-flex flex-wrap flex-grow-1">
<div class="width-100">
<div class="item item-hover width-100 d-flex ion-no-padding ion-no-margin"
*ngFor="let room of rooms"
[class.item-active]="room.id == idSelected" [class.hide-room]="room.roomType != segment">
<div class="item-icon">
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id != idSelected && room.roomType == RoomType.Group " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-chat-40.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id == idSelected && room.roomType == RoomType.Group" class="icon" slot="start" src="assets/images/theme/gov/icons-chat-chat-40-hover.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'default' && room.roomType == RoomType.Direct" class="icon" slot="start" src="assets/images/icons-chat-group-chat-40.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id != idSelected && room.roomType == RoomType.Direct" class="icon" slot="start" src="assets/images/theme/gov/icons-chat-group-chat-40.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id == idSelected && room.roomType == RoomType.Direct" class="icon" slot="start" src="assets/images/theme/gov/icons-chat-group-chat-40-hover.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' && room.id != idSelected && room.roomType == RoomType.Direct" class="icon" slot="start" src="assets/images/theme/{{ThemeService.currentTheme}}/icons-chat-group-chat-40.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' && room.id == idSelected && room.roomType == RoomType.Direct" class="icon" slot="start" src="assets/images/theme/{{ThemeService.currentTheme}}/icons-chat-group-chat-40-hover.svg"></ion-icon>
</div>
<div
(click)="openMessagesPage(room.id)"
class="item-content flex-grow-1 cursor-pointer"><!-- (click)="openMessages(dm)" -->
<div class="item-title-time">
<div class="item-title" [class.item-title-active]="room.id == idSelected">
<ion-label >
<span >
<div >
<div class="font-15-em" [class.bold-message]="boldTable?.[room.id]?.bold">
{{room.roomName}}
</div>
</div>
</span>
</ion-label>
</div>
<div class="item-date font-13-em" [class.item-date-active]="room.id == idSelected">
{{ room.displayDate }}
</div>
</div>
<div class="item-date font-13-em" [class.item-date-active]="room.id == idSelected">
<!-- {{ expirationDate[room.id] !== null ? expirationDate[room.id] + ' seconds left' : 'No expiration' }} -->
{{ expirationDate[room.id] !== null ? expirationDate[room.id] + ' seconds left' : '' }}
</div>
<div *ngIf="room?.messages?.[0]?.message" class="item-description d-flex align-items-center" [class.item-description-active]="room.id ==idSelected">
<div class="item-message font-13-em add-ellipsis white-space-nowrap"> {{room.messages[0].message}} </div>
<!-- <div class="item-message font-13-em add-ellipsis white-space-nowrap" *ngIf="room.otherUserType == false"> {{room.messages[0].message}} </div> -->
<!-- <div class="font-13-em" *ngIf="room.otherUserType == true">está escrever ...</div> -->
</div>
</div>
</div>
</div>
<div class="width-100" [ngSwitch]="segment">
<ion-list *ngSwitchCase="1">
<ion-item-sliding>
<div class="item item-hover width-100 d-flex ion-no-padding ion-no-margin"
*ngFor="let room of (items$ | async)"
[class.item-active]="room.id == idSelected" [class.hide-room]="room.roomType != 1">
<div class="item-icon">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="icon" slot="start" src="assets/images/icons-chat-group-chat-40.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id != idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-group-chat-40.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id == idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-group-chat-40-hover.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' && room.id != idSelected " class="icon" slot="start" src="assets/images/theme/{{ThemeService.currentTheme}}/icons-chat-group-chat-40.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' && room.id == idSelected " class="icon" slot="start" src="assets/images/theme/{{ThemeService.currentTheme}}/icons-chat-group-chat-40-hover.svg"></ion-icon>
</div>
<div
(click)="openMessagesPage(room.id)"
class="item-content flex-grow-1 cursor-pointer"><!-- (click)="openMessages(dm)" -->
<div class="item-title-time">
<div class="item-title" [class.item-title-active]="room.id == idSelected">
<ion-label >
<span >
<div >
<div class="font-15-em" [class.bold-message]="boldTable?.[room.id]?.bold">
{{room.roomName}}
</div>
</div>
</span>
</ion-label>
</div>
<div class="item-date font-13-em" [class.item-date-active]="room.id == idSelected">
{{ room.displayDate }}
</div>
</div>
<div class="item-date font-13-em" [class.item-date-active]="room.id == idSelected">
<!-- {{ expirationDate[room.id] !== null ? expirationDate[room.id] + ' seconds left' : 'No expiration' }} -->
{{ expirationDate[room.id] !== null ? expirationDate[room.id] + ' seconds left' : '' }}
</div>
<div *ngIf="room?.messages?.[0]?.message" class="item-description d-flex align-items-center" [class.item-description-active]="room.id ==idSelected">
<div class="item-message font-13-em add-ellipsis white-space-nowrap"> {{room.messages[0].message}} </div>
<!-- <div class="item-message font-13-em add-ellipsis white-space-nowrap" *ngIf="room.otherUserType == false"> {{room.messages[0].message}} </div> -->
<!-- <div class="font-13-em" *ngIf="room.otherUserType == true">está escrever ...</div> -->
</div>
</div>
</div>
</ion-item-sliding>
</ion-list>
<ion-list *ngSwitchCase="2">
<ion-item-sliding>
<div class="item item-hover width-100 d-flex ion-no-padding ion-no-margin"
*ngFor="let room of (items$ | async)"
[class.item-active]="room.id == idSelected" [class.hide-room]="room.roomType != 2">
<div class="item-icon">
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id != idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-chat-40.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id == idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-chat-40-hover.svg"></ion-icon>
</div>
<div
(click)="openMessagesPage(room.id)"
class="item-content flex-grow-1 cursor-pointer"><!-- (click)="openMessages(dm)" -->
<div class="item-title-time">
<div class="item-title" [class.item-title-active]="room.id == idSelected">
<ion-label >
<span >
<div >
<div class="font-15-em" [class.bold-message]="boldTable?.[room.id]?.bold">
{{room.roomName}}
</div>
</div>
</span>
</ion-label>
</div>
<div class="item-date font-13-em" [class.item-date-active]="room.id == idSelected">
{{ room.displayDate }}
</div>
<!-- <div class="item-date font-13-em" [class.item-date-active]="room.id == idSelected">{{room.duration}}</div> -->
</div>
<div class="item-date font-13-em" [class.item-date-active]="room.id == idSelected">
<!-- {{ expirationDate[room.id] !== null ? expirationDate[room.id] + ' seconds left' : 'No expiration' }} -->
{{ expirationDate[room.id] !== null ? expirationDate[room.id] + ' seconds left' : '' }}
</div>
<div *ngIf="room?.messages?.[0]?.message" class="item-description d-flex align-items-center" [class.item-description-active]="room.id ==idSelected">
<div class="item-message font-13-em add-ellipsis white-space-nowrap"> {{room?.messages?.[0]?.message}} </div>
<!-- <div class="item-message font-13-em add-ellipsis white-space-nowrap" *ngIf="room.otherUserType == false"> {{room?.messages?.[0]?.message}} </div> -->
<!-- <div class="font-13-em" *ngIf="room.otherUserType == true">está escrever ...</div> -->
</div>
</div>
</div>
</ion-item-sliding>
</ion-list>
</div>
<!-- <button (click)="sendMsg()" style="height: 41px;">Send message</button> -->
@@ -142,6 +108,7 @@
</app-empty-chat>
<app-messages class=" height-100 flex-column"
[room]="RoomSelected"
*ngIf="showMessages"
[style.display]="showMessages ? 'flex' : 'none'"
(closeAllDesktopComponents)="closeAllDesktopComponents()"
@@ -184,14 +151,14 @@
<app-edit-group [roomId]="roomId"
(closeAllDesktopComponents)="closeAllDesktopComponents()"
(openGroupMessage)="openGroupMessagesPage($event)"
(openGroupMessage)="openMessagesPage($event)"
*ngIf="showEditGroup"
[style.display]="showEditGroup ? 'flex' : 'none'"
class="height-100 flex-column">
</app-edit-group>
<app-group-contacts
(openGroupMessage)="openGroupMessagesPage($event)"
(openGroupMessage)="openMessagesPage($event)"
*ngIf="showGroupContacts"
[style.display]="showGroupContacts ? 'flex' : 'none'"
[roomId]="groupRoomId" class=" height-100 flex-column"
+69 -36
View File
@@ -19,13 +19,14 @@ import { Observable as DexieObservable } from 'Dexie';
import { EditGroupPage } from './modal/edit-group/edit-group.page';
import { ChatServiceService } from 'src/app/module/chat/domain/chat-service.service'
import { RoomLocalRepository } from 'src/app/module/chat/data/repository/room/room-local-repository.service'
import { map, tap } from 'rxjs/operators';
import { interval, Subscription } from 'rxjs';
import { map, switchMap, tap } from 'rxjs/operators';
import { BehaviorSubject, interval, Subscription } from 'rxjs';
import { RoomTable } from 'src/app/infra/database/dexie/instance/chat/schema/room';
import { RoomEntity, RoomType } from 'src/app/core/chat/entity/group';
import { BoldLocalRepository } from 'src/app/module/chat/data/repository/bold/bold-local-repository'
import { BoldTable } from 'src/app/infra/database/dexie/instance/chat/schema/bold';
import { RoomViewModel } from './store/model/room';
import { MessageLocalDataSourceService } from 'src/app/module/chat/data/repository/message/message-local-data-source.service'
@Component({
selector: 'app-chat',
templateUrl: './chat.page.html',
@@ -34,7 +35,7 @@ import { RoomViewModel } from './store/model/room';
export class ChatPage implements OnInit {
showLoader: boolean;
segment: RoomType = RoomType.Group
segment: RoomType = RoomType.Direct
idSelected: string;
roomId: any;
@@ -59,7 +60,7 @@ export class ChatPage implements OnInit {
// count$: Observable<RoomRemoteDataSourceState>;
//items$!: DexieObservable<RoomTable[]>;
items$!: Observable<RoomTable[]>;
private rooms: RoomTable[] = [];
rooms: RoomViewModel[] = [];
private subscription: Subscription;
expirationDate = {}
private intervalSubscription: Subscription;
@@ -67,6 +68,11 @@ export class ChatPage implements OnInit {
RoomType = RoomType
boldTable: {[key: string]: BoldTable} = {}
private roomListSubject = new BehaviorSubject<{ id: string, name: string }[]>([]);
roomsWithLastMessages: { name: string, lastMessage: any }[] = [];
private subscription1: Subscription;
RoomSelected!: RoomViewModel;
constructor(
private modalController: ModalController,
@@ -77,7 +83,8 @@ export class ChatPage implements OnInit {
public RouteService: RouteService,
private ChatServiceService: ChatServiceService,
private roomLocalDataSourceService: RoomLocalRepository,
private boldLocalRepository: BoldLocalRepository
private boldLocalRepository: BoldLocalRepository,
private MessageLocalDataSourceService: MessageLocalDataSourceService
) {
window.onresize = (event) => {
@@ -100,20 +107,61 @@ export class ChatPage implements OnInit {
}
// Method to update the room list
// updateRoomList(newRoomList: { id: string, name: string }[]): void {
// this.roomListSubject.next(newRoomList);
// }
// Fetch all items using useLiveQuery
ngOnInit() {
this.items$ = this.roomLocalDataSourceService.getItemsLive().pipe(
updatemessage(sortedRooms) {
this.rooms = sortedRooms
this.rooms.sort((a, b) =>
new Date(b.messages?.[0]?.sentAt as string).getTime() -
new Date(a.messages?.[0]?.sentAt as string).getTime()
);
this.RoomSelected = this.rooms.filter(e => e.id == this.idSelected)[0]
}
ngOnInit() {
// this.subscription = this.roomListSubject.pipe(
// switchMap(roomList =>
// this.MessageLocalDataSourceService.getLastMessageForRooms(roomList.map(room => room.id))
// )
// ).subscribe(lastMessages => {
// this.roomsWithLastMessages = this.roomListSubject.value.map(room => ({
// name: room.name,
// lastMessage: lastMessages.find(msg => msg.roomId === room.id)?.message || null
// }));
// this.roomsWithLastMessages.sort((a, b) =>
// new Date(b.lastMessage.messages?.[0]?.sentAt as unknown as string) as unknown as number -
// (new Date(a.lastMessage.messages?.[0]?.sentAt as unknown as string) as any) as unknown as number
// )
// });
// // Initialize room list (can be loaded from a service, API, etc.)
// this.roomListSubject.next([
// { id: '1135e73c-af8e-416c-a51f-1602b4770cf7', name: 'Room 1' }
// // Add more rooms as needed
// ]);
this.roomLocalDataSourceService.getItemsLive().pipe(
map((roomList) => roomList.map((room)=> new RoomViewModel(room))),
tap((roomList) => {
this.rooms = roomList.sort((a, b) =>
new Date(b.messages?.[0]?.sentAt as unknown as string) as unknown as number -
(new Date(a.messages?.[0]?.sentAt as unknown as string) as any) as unknown as number
)
roomList.sort((a, b) =>
new Date(b.messages?.[0]?.sentAt as string).getTime() -
new Date(a.messages?.[0]?.sentAt as string).getTime()
);
console.log('update')
this.updatemessage(roomList)
})
);
).subscribe()
// Create the interval observable
const interval$ = interval(1000).pipe(
@@ -286,9 +334,10 @@ export class ChatPage implements OnInit {
this.idSelected = '';
this.showEmptyComponent = true;
}
openGroupContactsPage(data) {
openGroupContactsPage(roomId) {
this.idSelected = '';
this.groupRoomId = data;
this.groupRoomId = roomId;
this.RoomSelected = this.rooms.filter(e => e.id == roomId)[0]
this.closeAllDesktopComponents();
if (window.innerWidth < 701) {
@@ -299,15 +348,16 @@ export class ChatPage implements OnInit {
}
openMessagesPage(rid) {
openMessagesPage(roomId) {
// this.chatService.refreshtoken();
this.roomId = rid;
this.roomId = roomId;
this.RoomSelected = this.rooms.filter(e => e.id == roomId)[0]
if (window.innerWidth < 701) {
this.openMessagesModal(rid);
this.openMessagesModal(roomId);
}
else {
this.idSelected = rid;
this.idSelected = roomId;
this.closeAllDesktopComponents();
this.showEmptyComponent = false;
this.showMessages = true;
@@ -351,23 +401,6 @@ export class ChatPage implements OnInit {
}
}
openGroupMessagesPage(rid) {
this.roomId = rid;
if (window.innerWidth < 701) {
this.openGroupMessagesModal(rid);
}
else {
this.idSelected = rid;
this.closeAllDesktopComponents();
this.showEmptyComponent = false;
this.showMessages = true;
}
}
doRefresh(event) {
setTimeout(() => {
try {
@@ -1,17 +0,0 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AddUserPage } from './add-user.page';
const routes: Routes = [
{
path: '',
component: AddUserPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class AddUserPageRoutingModule {}
@@ -1,20 +0,0 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { AddUserPageRoutingModule } from './add-user-routing.module';
import { AddUserPage } from './add-user.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
AddUserPageRoutingModule
],
declarations: [AddUserPage]
})
export class AddUserPageModule {}
@@ -1,9 +0,0 @@
<ion-header>
<ion-toolbar>
<ion-title>addUser</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
</ion-content>
@@ -1,24 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { AddUserPage } from './add-user.page';
describe('AddUserPage', () => {
let component: AddUserPage;
let fixture: ComponentFixture<AddUserPage>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ AddUserPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(AddUserPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,15 +0,0 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-add-user',
templateUrl: './add-user.page.html',
styleUrls: ['./add-user.page.scss'],
})
export class AddUserPage implements OnInit {
constructor() { }
ngOnInit() {
}
}
@@ -3,12 +3,12 @@
<div class="main-header">
<div class="header-top">
<div class="middle" >
<ion-label class="title" *ngIf="roomData$ | async as roomData"> {{ roomData.roomName }}</ion-label>
<ion-label class="title" > {{ room.roomName }}</ion-label>
<!-- <button (click)="ChatMessageDebuggingPage()">Dev</button> -->
<span *ngIf="roomStatus$ | async as roomStatus"><ion-icon *ngIf="roomStatus" class="online" name="ellipse"></ion-icon></span>
</div>
<div class="right">
<button title="Menu" class="btn-no-color" (click)="_openMessagesOptions()" *ngIf="roomType == RoomTypeEnum.Group">
<button title="Menu" class="btn-no-color" (click)="_openMessagesOptions()" *ngIf="room.roomType == RoomTypeEnum.Group">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/theme/blue/icons-menu.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " src="assets/images/theme/gov/icons-menu.svg">
</ion-icon>
@@ -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 { tap } from 'rxjs/operators';
import { map, 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,6 +50,8 @@ 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',
@@ -112,7 +114,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
@ViewChild('array') myInputRef!: ElementRef;
userName = "";
room: any = new Array();
@Input() room!: RoomViewModel;
roomName: any;
isAdmin = true;
roomCountDownDate: string;
@@ -120,7 +122,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
textField = ''
roomData$: DexieObservable<RoomTable | undefined>
roomData$: Observable<RoomTable | undefined>
roomStatus$: DexieObservable<Boolean >
roomMessage$: DexieObservable<MessageTable[]>
roomMembers$: Observable<MemberTable[] | undefined>
@@ -135,6 +137,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
messages: MessageEntity[] = []
RoomDataSubject: Subscription
messageReceiveSubject: Subscription
messageDeleteSubject: Subscription
messageUpdateSubject: Subscription
@@ -179,7 +182,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()
@@ -226,17 +229,6 @@ 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();
@@ -276,6 +268,15 @@ 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) {
@@ -318,9 +319,9 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.messageOnReconnectSubject?.unsubscribe()
this.messageOnReconnectSubject = this.chatServiceService.listenToMessageLoadHistory({roomId: this.roomId}).subscribe((messages) => {
console.log('message', messages);
for(const message of messages.data) {
const found = this.messages1[this.roomId].find((e) => e.id == message.id)
@@ -425,7 +426,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.chatServiceService.removeBoldFromRoom({roomId: this.roomId})
});
}
listenToDeleteMessage() {
@@ -469,7 +470,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.messageSendSubject = this.chatServiceService.listenToSendMessage(this.roomId).subscribe((updateMessage) => {
console.log({updateMessage},'=--=-=-=--=', this.messages1[this.roomId])
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.roomType)
this.chatServiceService.sendMessage(message, this.room.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.roomType)
const data = await this.chatServiceService.sendMessage(message, this.room.roomType)
}
@@ -898,7 +898,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
roomId: this.roomId,
members: [],
isAdmin: this.isAdmin,
roomType: this.roomType
roomType: this.room.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.roomType)
this.chatServiceService.sendMessage(message, this.room.roomType)
}
@@ -1036,7 +1036,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
setTimeout(() => {
this.scrollToBottomClicked()
}, 100)
this.chatServiceService.sendMessage(message, this.roomType)
this.chatServiceService.sendMessage(message, this.room.roomType)
this.textField = ''
}
@@ -1126,7 +1126,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
setTimeout(() => {
this.scrollToBottomClicked()
}, 100)
this.chatServiceService.sendMessage(message, this.roomType)
this.chatServiceService.sendMessage(message, this.room.roomType)
}
}
@@ -1182,7 +1182,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
setTimeout(() => {
this.scrollToBottomClicked()
}, 100)
this.chatServiceService.sendMessage(message, this.roomType)
this.chatServiceService.sendMessage(message, this.room.roomType)
}
} else {
@@ -131,9 +131,8 @@ export class NewGroupPage implements OnInit{
members: []
})
console.log(result)
if(result.isOk()) {
await this.ChatServiceService.getRoomById(result.value.id)
this.addGroupMessage.emit(result.value.id);
} else if(result.error instanceof HttpErrorResponse) {
this.httpErrorHandle.httpStatusHandle(result.error)
@@ -20,7 +20,7 @@ import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
//======
import { Observable as DexieObservable } from 'Dexie';
import { Subscription } from 'rxjs';
import { Observable, Subscription } from 'rxjs';
import { MessageTable } from 'src/app/infra/database/dexie/instance/chat/schema/message';
import { ChatServiceService } from 'src/app/module/chat/domain/chat-service.service';
import { EditMessagePage } from 'src/app/ui/chat/modal/edit-message/edit-message.page';
@@ -109,7 +109,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
audioPermissionStatus: 'granted' | 'denied' | 'prompt' | null = null
sessionStore = SessionStore
roomData$: DexieObservable<RoomTable | undefined>
roomData$: Observable<RoomTable | undefined>
roomStatus$: DexieObservable<Boolean >
roomMessage$: DexieObservable<MessageTable[]>
roomMembers$: DexieObservable<MemberTable[] | undefined>
@@ -17,7 +17,7 @@ export class RoomInfoPage implements OnInit {
roomId:string;
roomMembers$: Observable<MemberTable[] | undefined>
roomData$: DexieObservable<RoomTable | undefined>
roomData$: Observable<RoomTable | undefined>
constructor(
private navParams: NavParams,