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
+26 -23
View File
@@ -42,59 +42,59 @@
<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">
[class.item-active]="room.$id == selectedRoomId" [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 == 'gov' && room.$id != selectedRoomId && 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 == selectedRoomId && 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>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.$id != selectedRoomId && 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 == selectedRoomId && 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 != selectedRoomId && 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 == selectedRoomId && 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)" -->
(click)="openMessagesPage(room.$id)" class="item-content flex-grow-1 cursor-pointer"><!-- (click)="openMessages(dm)" -->
<div class="item-title-time">
<div class="item-title add-ellipsis" [class.item-title-active]="room.id == idSelected">
<div class="item-title add-ellipsis" [class.item-title-active]="room.$id == selectedRoomId">
<ion-label >
<span >
<div >
<div class="font-15-em add-ellipsis" [class.bold-message]="boldTable?.[room.id]?.bold">
<div class="font-15-em add-ellipsis" [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">
<div class="item-date font-13-em" [class.item-date-active]="room.$id == selectedRoomId">
{{ 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 class="item-date font-13-em" [class.item-date-active]="room.$id == selectedRoomId">
<!-- {{ expirationDate[room.$id] !== null ? expirationDate[room.$id] + ' seconds left' : 'No expiration' }} -->
<span *ngIf="expirationDate[room.$id]"> {{ expirationDate[room.$id] !== null ? expirationDate[room.$id] + ' seconds left' : '' }} </span>
</div>
<div *ngIf="room?.messages?.length >= 1 && room.messages[0].isDeleted!=true" class="item-description d-flex align-items-center" [class.item-description-active]="room.id ==idSelected">
<div *ngIf="room?.messages?.length >= 1 && room.messages[0].isDeleted!=true" class="item-description d-flex align-items-center" [class.item-description-active]="room.$id ==selectedRoomId">
<!-- -->
<!-- <div *ngIf="room?.messages?.[0]?.message" class="item-description d-flex align-items-center" [class.item-description-active]="room.id ==idSelected"> -->
<!-- <div *ngIf="room?.messages?.[0]?.message" class="item-description d-flex align-items-center" [class.item-description-active]="room.$id ==selectedRoomId"> -->
<!-- <div class="item-message" *ngIf="group.otherUserType == false">{{room?.messages?.[0]?.message.u.name}}: {{room?.messages?.[0]?.message.msg}} </div> -->
<div class="item-message font-13-em add-ellipsis white-space-nowrap"> {{room.messages[0].message}} </div>
<!-- <div *ngIf="group.otherUserType == true">{{group.userThatIsTyping}} está escrever ...</div> -->
<div class="item-files add-ellipsis" *ngIf="room.messages[0]?.attachments?.length >= 1">
<fa-icon *ngIf="room.lastMessageDocument" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="room.id == idSelected"></fa-icon>
<fa-icon *ngIf="room?.messages?.[0]?.attachments[0]?.mimeType == 'application/audio'" icon="file-audio" class="file-icon" [class.set-active-item-font-to-white]="room.id == idSelected"></fa-icon>
<fa-icon *ngIf="room.lastMessageDocument" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="room.$id == selectedRoomId"></fa-icon>
<fa-icon *ngIf="room?.messages?.[0]?.attachments[0]?.mimeType == 'application/audio'" icon="file-audio" class="file-icon" [class.set-active-item-font-to-white]="room.$id == selectedRoomId"></fa-icon>
<span *ngIf="room?.messages?.[0]?.attachments[0]?.mimeType == 'application/audio'" class="item-files-title"> audio </span>
<fa-icon *ngIf="room?.messages?.[0]?.attachments[0]?.mimeType == 'application/meeting'" icon="calendar-alt" class="file-icon" [class.set-active-item-font-to-white]="room.id == idSelected"></fa-icon>
<fa-icon *ngIf="room?.messages?.[0]?.attachments[0]?.mimeType == 'application/meeting'" icon="calendar-alt" class="file-icon" [class.set-active-item-font-to-white]="room.$id == selectedRoomId"></fa-icon>
<fa-icon *ngIf="room.lastMessageImage" icon="image"></fa-icon>
<span class="pl-2 font-13-em add-ellipsis">{{ room.messages[0].attachments[0].description }}</span>
</div>
<!-- <div class="item-files" *ngIf="room.attachments">
<div *ngIf="room.value.lastMessage.attachments[0].image_url">
<fa-icon icon="image" class="file-icon" [class.set-active-item-font-to-white]="room.id == idSelected"></fa-icon>
<fa-icon icon="image" class="file-icon" [class.set-active-item-font-to-white]="room.$id == selectedRoomId"></fa-icon>
<span> Fotografia</span>
</div>
</div> -->
@@ -127,7 +127,8 @@
</app-empty-chat>
<app-messages class=" height-100 flex-column"
[room]="RoomSelected"
[_room]="RoomSelected"
*ngIf="showMessages"
[style.display]="showMessages ? 'flex' : 'none'"
(closeAllDesktopComponents)="closeAllDesktopComponents()"
@@ -139,13 +140,15 @@
[style.display]="showMessages ? 'flex' : 'none'"
[roomId]="roomId"
[receiverId]="selectedReceiverId"
[showMessages]="showMessages" #messagecontainer>
</app-messages>
<app-contacts
(openMessage)="openMessagesPage($event)"
(backToChat)="backToChat($event)"
(backToChat)="openMessagesWithOutValidation($event)"
(openMessagesToStartDirectConversation)="openMessagesToStartDirectConversation($event)"
(emptyTextDescriptionOpen)="emptyTextDescriptionOpen()"
(closeAllDesktopComponents)="closeAllDesktopComponents()"
*ngIf="showContacts"
@@ -157,7 +160,7 @@
<app-new-group
(addGroupMessage)="openGroupContactsPage($event)"
[roomId]="roomId"
(backToChat)="backToChat($event)"
(backToChat)="openMessagesWithOutValidation($event)"
(closeAllDesktopComponents)="closeAllDesktopComponents()"
(openGroupContacts)="openGroupContactsPage($event)"
(openEditGroupPage)="openEditGroupPage($event)"
+66 -30
View File
@@ -1,4 +1,5 @@
import {
ChangeDetectorRef,
Component,
OnInit,
} from '@angular/core';
@@ -25,6 +26,7 @@ import { BoldTable } from 'src/app/infra/database/dexie/instance/chat/schema/bol
import { RoomViewModel } from './store/model/room';
import { MessageLocalDataSourceService } from 'src/app/module/chat/data/repository/message/message-local-data-source.service'
import { ToastService } from 'src/app/services/toast.service';
import { Logger } from 'src/app/services/logger/main/service';
@Component({
selector: 'app-chat',
templateUrl: './chat.page.html',
@@ -34,7 +36,8 @@ export class ChatPage implements OnInit {
showLoader: boolean;
segment: RoomType = RoomType.Direct
idSelected: string;
selectedRoomId: string;
selectedReceiverId: string;
roomId: any;
groupRoomId: any;
@@ -83,7 +86,7 @@ export class ChatPage implements OnInit {
private roomLocalDataSourceService: RoomLocalRepository,
private boldLocalRepository: BoldLocalRepository,
private MessageLocalDataSourceService: MessageLocalDataSourceService,
private toastService: ToastService,
private toastService: ToastService
) {
window.onresize = (event) => {
@@ -111,12 +114,11 @@ export class ChatPage implements OnInit {
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()
new Date(b.messages?.[0]?.sentAt as string || b.createdAt ).getTime() -
new Date(a.messages?.[0]?.sentAt as string || a.createdAt).getTime()
);
// this.RoomSelected = this.rooms.filter(e => e.id == this.idSelected)[0]
// this.RoomSelected = this.rooms.filter(e => e.id == this.selectedRoomId)[0]
}
ngOnInit() {
// this.subscription = this.roomListSubject.pipe(
@@ -143,14 +145,7 @@ export class ChatPage implements OnInit {
this.roomLocalDataSourceService.getItemsLive().pipe(
map((roomList) => roomList.map((room)=> new RoomViewModel(room))),
tap((roomList) => {
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()
@@ -159,7 +154,10 @@ export class ChatPage implements OnInit {
const interval$ = interval(1000).pipe(
tap(() => {
for (const room of this.rooms) {
this.expirationDate[room.id] = this.getSecondsLeft(room.expirationDate);
if(room.expirationDate) {
this.expirationDate[room.$id] = this.getSecondsLeft(room.expirationDate);
}
}
})
);
@@ -290,7 +288,7 @@ export class ChatPage implements OnInit {
hideRefreshButton() {
window.onresize = (event) => {
if (window.innerWidth < 701) {
this.idSelected = '';
this.selectedRoomId = '';
this.hideRefreshBtn = false;
this.closeAllDesktopComponents()
@@ -298,13 +296,13 @@ export class ChatPage implements OnInit {
}
else {
this.hideRefreshBtn = true;
if (this.idSelected == '') {
if (this.selectedRoomId == '') {
this.showEmptyComponent = true;
}
}
}
if (window.innerWidth < 701) {
this.idSelected = '';
this.selectedRoomId = '';
this.hideRefreshBtn = false;
}
}
@@ -323,13 +321,13 @@ export class ChatPage implements OnInit {
}
showEmptyContainer() {
this.idSelected = '';
this.selectedRoomId = '';
this.showEmptyComponent = true;
}
openGroupContactsPage(roomId) {
this.idSelected = '';
this.selectedRoomId = '';
this.groupRoomId = roomId;
this.RoomSelected = this.rooms.filter(e => e.id == roomId)[0]
this.RoomSelected = this.rooms.filter(e => e.$id == roomId)[0]
this.closeAllDesktopComponents();
if (window.innerWidth < 701) {
@@ -340,17 +338,19 @@ export class ChatPage implements OnInit {
}
openMessagesPage(roomId) {
openMessagesPage($roomId: string) {
// this.chatService.refreshtoken();
this.roomId = roomId;
this.RoomSelected = this.rooms.filter(e => e.id == roomId)[0]
this.roomId = $roomId;
const exist = this.rooms.filter(e => e.$id == $roomId)[0]
if(this.RoomSelected?.id) {
if(exist) {
this.RoomSelected = exist
this.selectedRoomId = exist.$id;
if (window.innerWidth < 701) {
this.openMessagesModal(roomId);
this.openMessagesModal($roomId);
}
else {
this.idSelected = roomId;
this.selectedRoomId = $roomId;
this.closeAllDesktopComponents();
this.showEmptyComponent = false;
this.showMessages = true;
@@ -360,10 +360,40 @@ export class ChatPage implements OnInit {
// this.toastService._badRequest("Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.")
}
// Trigger change detection manually
}
openMessagesWithOutValidation(roomId: string) {
if (window.innerWidth < 701) {
// this.openMessagesModal(roomId);
}
else {
this.selectedRoomId = roomId;
this.selectedReceiverId = undefined
this.closeAllDesktopComponents();
this.showEmptyComponent = false;
this.showMessages = true;
}
}
openMessagesToStartDirectConversation(room: RoomViewModel) {
if (window.innerWidth < 701) {
// this.openMessagesModal(roomId);
}
else {
this.roomId = null;
this.selectedRoomId = room.$id;
console.log('RoomSelected', room)
this.RoomSelected = room
this.closeAllDesktopComponents();
this.showEmptyComponent = false;
this.showMessages = true;
}
}
openContactsPage() {
this.segment = RoomType.Direct;
this.idSelected = '';
this.selectedRoomId = '';
this.closeAllDesktopComponents();
if (window.innerWidth < 701) {
@@ -377,7 +407,7 @@ export class ChatPage implements OnInit {
openNewGroupPage() {
this.segment = RoomType.Group;
this.idSelected = '';
this.selectedRoomId = '';
if (window.innerWidth < 701) {
this.newGroup();
}
@@ -492,8 +522,14 @@ export class ChatPage implements OnInit {
// this.segment = "Grupos"
// this.openGroupMessagesPage(room.id);
//} else {
// this.segment = RoomType.Direct
this.openMessagesPage(roomId);
// this.segment = RoomType.Direct
this.openMessagesPage(roomId);
if(typeof roomId != 'string') {
Logger.error('roomId must be string', {
roomId
})
}
// }
}
@@ -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())
}
}
}
@@ -3,13 +3,12 @@
<div class="main-header">
<div class="header-top">
<div class="middle" >
<!-- <ion-label class="title" *ngIf="(roomData$ | async) === null"> {{ room.roomName }}</ion-label> -->
<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()" >
<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>
@@ -44,7 +43,7 @@
<div class="messages height-100 width-100 d-flex flex-column rotate-div" #scrollMe >
<div
*ngFor="let message of messages1[roomId]; let messageIndex = index" class="messages-list-item-wrapper px-10-em"
*ngFor="let message of messages1[room?.$id]; let messageIndex = index" class="messages-list-item-wrapper px-10-em"
[ngClass]="{
'info-meeting': message.messageType == IMessageType.information && !message.ballon,
'info-ballon': message.ballon == true,
@@ -3,11 +3,8 @@ import { AnimationController, GestureController, IonRange, ModalController, Popo
import { ToastService } from 'src/app/services/toast.service';
import { ContactsPage } from '../contacts/contacts.page';
import { ChatOptionsFeaturesPage } from 'src/app/modals/chat-options-features/chat-options-features.page';
import { TimeService } from 'src/app/services/functions/time.service';
import { FileService } from 'src/app/services/functions/file.service';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { ThemeService } from 'src/app/services/theme.service';
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
import { FileType } from 'src/app/models/fileType';
import { SearchPage } from 'src/app/pages/search/search.page';
import { CameraResultType } from '@capacitor/camera';
@@ -53,6 +50,9 @@ import { RoomViewModel } from '../../store/model/room';
import { MessageViewModal } from '../../store/model/message';
import { XBallon } from '../../utils/messageBallon';
import { whatsappDate } from 'src/app/ui/shared/utils/whatappdate';
import { IDBoolean } from 'src/app/infra/database/dexie/type';
import { Result } from 'neverthrow';
import { MessageOutPutDataDTO } from 'src/app/core/chat/repository/dto/messageOutputDTO';
@Component({
selector: 'app-messages',
templateUrl: './messages.page.html',
@@ -72,7 +72,9 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
roomType!: RoomType
RoomTypeEnum = RoomType
@Input() room!: RoomViewModel
@Input() _room!: RoomViewModel
room!: RoomViewModel
@Input() roomId: string;
@Input() showMessages: string;
@@ -114,8 +116,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
@ViewChild('range', { static: false }) range: IonRange;
@ViewChild('array') myInputRef!: ElementRef;
userName = "";
roomName: any;
isAdmin = true;
roomCountDownDate: string;
audioMimeType = ''
@@ -152,9 +152,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
totalMembers = 0
members: MemberTable[] = []
private worker: SharedWorker;
private port: MessagePort;
date: {[key: string]: Object} = {}
handleClickActive = true
@@ -163,8 +160,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
private modalController: ModalController,
private animationController: AnimationController,
private toastService: ToastService,
private timeService: TimeService,
private fileService: FileService,
private gestureController: GestureController,
public ThemeService: ThemeService,
private sanitiser: DomSanitizer,
@@ -192,21 +187,32 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
ngOnChanges(changes: SimpleChanges): void {
this.roomData$ = this.RoomLocalRepository.getRoomByIdLive(this.roomId)
this.room = {...this._room} as any
console.log('message', this.room)
if(this.room.local == IDBoolean.false) {
this.getMessages()
this.subscribeToChanges()
} else {
this.getMessages()
}
this.roomData$ = this.RoomLocalRepository.getRoomByIdLive(this.room.$id)
this.roomData$.subscribe(e => {
if(e) {
this.roomType = e.roomType
this.room = new RoomViewModel(e)
this.roomType = e.roomType;
}
})
}
this.getMessages();
subscribeToChanges() {
this.listenToIncomingMessage();
this.listenToDeleteMessage();
this.listenToUpdateMessage();
this.listenToSendMessage();
this.roomMembers$ = this.MemberListLocalRepository.getRoomMemberByIdLive(this.roomId).pipe(
this.roomMembers$ = this.MemberListLocalRepository.getRoomMemberByIdLive(this.room.id).pipe(
tap((members) => {
this.totalMembers = members.length
this.members = members
@@ -218,10 +224,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
})
)
this.roomStatus$ = this.MemberListLocalRepository.allMemberOnline(this.roomId)
this.roomStatus$ = this.MemberListLocalRepository.allMemberOnline(this.room.id)
this.messageTypingSubject?.unsubscribe()
this.messageTypingSubject = this.userTypingLocalRepository.getUserTypingLiveByRoomId(this.roomId).subscribe((e) => {
this.messageTypingSubject = this.userTypingLocalRepository.getUserTypingLiveByRoomId(this.room.id).subscribe((e) => {
const arrayNames = e.filter((b)=> b.userId != SessionStore.user.UserId).map(e => e.userName)
this.userTyping$ = e as any
@@ -235,12 +241,22 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}) as any
this.chatServiceService.removeBoldFromRoom({roomId: this.roomId})
this.chatServiceService.getRoomById(this.roomId)
this.updateRoomDetails()
}
updateRoomDetails() {
if(!this.room?.local) {
this.chatServiceService.getRoomById(this.room.id)
}
}
removeBold() {
if(!this.room?.local) {
this.chatServiceService.removeBoldFromRoom({roomId: this.room.$id})
}
}
@HostListener('document:click', ['$event'])
handleClickOutside(event: Event) {
if (!this.handleClickActive) return;
@@ -274,76 +290,74 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
async getMessages() {
// dont remove this line
this.messages1[this.roomId] = []
let messages = await this.messageLocalDataSourceService.getItems(this.roomId)
this.messages1[this.room.$id] = []
let messages = await this.chatServiceService.messageLocalGetById({
roomId: this.room.id,
receiverId: this.room?.receiverId?.toString()
})
this.messages1[this.roomId] = []
this.date = {}
const allMessage = [];
if(messages.isOk()) {
this.messages1[this.room.$id] = []
this.date = {}
const allMessage = [];
// let ids = {}
// messages = messages.filter((message: any) => {
// if (message.$createAt) {
// if (!ids[message.$createAt]) {
// ids[message.$createAt] = true;
// return true; // Keep this message
// } else {
// console.log('delete');
// return false; // Remove this message
// }
// }
// return true; // Keep messages without an id
// });
console.time("mappingTime");
for(const message of messages) {
const date = whatsappDate(message.sentAt, false)
if(!this.date[date]) {
this.date[date] = true
const Ballon = XBallon(message)
allMessage.push(Ballon)
console.time("mappingTime");
const sortMessages = messages.value.sort((a, b) => new Date(a.sentAt).getTime() - new Date(b.sentAt).getTime())
for(const message of sortMessages) {
const date = whatsappDate(message.sentAt, false)
if(!this.date[date]) {
this.date[date] = true
const Ballon = XBallon(message)
allMessage.push(Ballon)
}
allMessage.push(new MessageViewModal(message))
}
console.timeEnd("mappingTime");
this.messages1[this.room.$id]
this.messages1[this.room.$id] = allMessage
// if(messages.length >= 1) {
// this.messages1[this.room.$id].push(LastMessage)
// }
this.loadAttachment()
setTimeout(() => {
this.sendReadMessage()
}, 1000)
if(this.room.$id) {
this.onReconnectGetMessages()
}
allMessage.push(new MessageViewModal(message))
}
console.timeEnd("mappingTime");
this.messages1[this.roomId] = allMessage
// if(messages.length >= 1) {
// this.messages1[this.roomId].push(LastMessage)
// }
this.loadAttachment()
setTimeout(() => {
this.sendReadMessage()
}, 1000)
}
onReconnectGetMessages() {
this.messageOnReconnectSubject?.unsubscribe()
this.messageOnReconnectSubject = this.chatServiceService.listenToMessageLoadHistory({roomId: this.roomId}).subscribe((messages) => {
this.messageOnReconnectSubject = this.chatServiceService.listenToMessageLoadHistory({roomId: this.room.id}).subscribe((messages) => {
for(const message of messages.data) {
const found = this.messages1[this.roomId].find((e) => e.id == message.id)
const found = this.messages1[this.room.$id].find((e) => e.id == message.id)
if(!found) {
const msg = new MessageViewModal(message as any)
Object.assign(msg, message)
this.messages1[this.roomId].push(msg)
this.messages1[this.room.$id].push(msg)
}
}
this.messages1[this.roomId].sort((a, b) => {
this.messages1[this.room.$id].sort((a, b) => {
return new Date(a.sentAt).getTime() - new Date(b.sentAt).getTime()
})
})
}
async loadAttachment() {
for(const message of this.messages1[this.roomId]) {
for(const message of this.messages1[this.room.$id]) {
if(message.hasAttachment && message.attachments[0].source != MessageAttachmentSource.Webtrix) {
this.chatServiceService.getMessageAttachmentByMessageId(message).then((result)=> {
@@ -368,7 +382,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.scrollToBottom();
}, 100)
this.messages1[this.roomId].splice(index, 1);
this.messages1[this.room.$id].splice(index, 1);
}
}
@@ -393,39 +407,40 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
sendReadMessage() {
for(const message of this.messages1[this.roomId]) {
if(this.room.local == IDBoolean.false) {
for(const message of this.messages1[this.room.$id]) {
if(!message.meSender()) {
const me = message.haveSeen(message.info)
if(!message.meSender()) {
const me = message.haveSeen(message.info)
if(!me) {
Logger.info('send read at, sender '+ message.sender.wxFullName+ ' '+ message.message +'message id'+ message.id)
if(!me) {
Logger.info('send read at, sender '+ message.sender.wxFullName+ ' '+ message.message +'message id'+ message.id)
this.chatServiceService.sendReadAt({
memberId: SessionStore.user.UserId,
messageId: message.id,
requestId: '',
roomId: this.roomId
})
this.chatServiceService.sendReadAt({
memberId: SessionStore.user.UserId,
messageId: message.id,
requestId: '',
roomId: this.room.$id
})
}
}
}
}
}
listenToIncomingMessage() {
this.messageReceiveSubject?.unsubscribe();
this.messageReceiveSubject = this.chatServiceService.listenToIncomingMessage(this.roomId).subscribe(async (_message) => {
this.messageReceiveSubject = this.chatServiceService.listenToIncomingMessage(this.room.id).subscribe(async (_message) => {
const date = whatsappDate(_message.sentAt, false)
if(!this.date[date]) {
this.date[date] = true
const Ballon = XBallon(_message)
this.messages1[this.roomId].push(Ballon)
this.messages1[this.room.$id].push(Ballon)
}
const message = new MessageViewModal(_message)
this.messages1[this.roomId].push(new MessageViewModal(message))
this.messages1[this.room.$id].push(new MessageViewModal(message))
if(message.hasAttachment) {
@@ -450,7 +465,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
setTimeout(() => {
this.chatServiceService.removeBoldFromRoom({roomId: this.roomId})
this.removeBold()
}, 1000)
});
@@ -459,23 +474,23 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
listenToDeleteMessage() {
this.messageDeleteSubject?.unsubscribe();
this.messageDeleteSubject = this.chatServiceService.listenToDeleteMessage(this.roomId).subscribe((deleteMessage) => {
this.messageDeleteSubject = this.chatServiceService.listenToDeleteMessage(this.room.id).subscribe((deleteMessage) => {
console.log('delete class', deleteMessage);
const index = this.messages1[this.roomId].findIndex(e =>
const index = this.messages1[this.room.$id].findIndex(e =>
typeof e?.id == 'string' && e?.id === deleteMessage.id ||
typeof e?.requestId == 'string' && e?.requestId == deleteMessage.requestId);
try {
console.log(this.messages1[this.roomId][index])
this.messages1[this.roomId][index].delete()
} catch (e) {
console.log('delete', e)
}
console.log(this.messages1[this.room.$id][index])
this.messages1[this.room.$id][index].delete()
} catch (e) {
console.log('delete', e)
}
// if (index !== -1) { // Check if the item was found
// console.log('delete ==')
// this.messages1[this.roomId].splice(index, 1);
// this.messages1[this.room.$id].splice(index, 1);
// // console.log('removed index', index);
// } else {
// // console.log('message not found');
@@ -486,14 +501,17 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
listenToUpdateMessage() {
this.messageUpdateSubject?.unsubscribe();
this.messageUpdateSubject = this.chatServiceService.listenToUpdateMessage(this.roomId).subscribe((updateMessage) => {
console.log('liste to update')
this.messageUpdateSubject = this.chatServiceService.listenToUpdateMessage(this.room.id).subscribe((updateMessage) => {
const index = this.messages1[this.roomId].findIndex(e => e?.id === updateMessage.id); // Use triple equals for comparison
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.roomId][index].info = updateMessage.info
this.messages1[this.roomId][index].message = updateMessage.message
this.messages1[this.roomId][index].reactions = updateMessage.reactions
this.messages1[this.room.$id][index].info = updateMessage.info
this.messages1[this.room.$id][index].message = updateMessage.message
this.messages1[this.room.$id][index].reactions = updateMessage.reactions
} else {
// console.log('message not found');
}
@@ -504,20 +522,20 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
listenToSendMessage() {
this.messageSendSubject?.unsubscribe();
this.messageSendSubject = this.chatServiceService.listenToSendMessage(this.roomId).subscribe((updateMessage) => {
this.messageSendSubject = this.chatServiceService.listenToSendMessage(this.room.id).subscribe((updateMessage) => {
const index = this.messages1[this.roomId].findIndex(e => e?.requestId === updateMessage.requestId); // Use triple equals for comparison
const index = this.messages1[this.room.$id].findIndex(e => e?.requestId === updateMessage.requestId); // Use triple equals for comparison
if (index !== -1) { // Check if the item was found
this.messages1[this.roomId][index].id = updateMessage.id
this.messages1[this.roomId][index].info = updateMessage.info
this.messages1[this.room.$id][index].id = updateMessage.id
this.messages1[this.room.$id][index].info = updateMessage.info
let attachmentIndex = 0;
for(const message of updateMessage.attachments) {
this.messages1[this.roomId][index].attachments[attachmentIndex].id = message.id
this.messages1[this.room.$id][index].attachments[attachmentIndex].id = message.id
attachmentIndex++;
}
@@ -545,7 +563,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.chatServiceService.reactToMessage({
memberId: SessionStore.user.UserId,
messageId: message.id,
roomId: this.roomId,
roomId: this.room.id,
reaction: emoji,
requestId: ''
})
@@ -554,13 +572,15 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
sendReadAt() {
// this.chatServiceService.messageMarkAsRead({roomId: this.roomId}).then((e) => {
// this.chatServiceService.messageMarkAsRead({roomId: this.room.$id}).then((e) => {
// console.log(e)
// })
}
sendTyping() {
this.UserTypingRemoteRepositoryService.sendTyping(this.roomId)
if(this.room.local == IDBoolean.false) {
this.UserTypingRemoteRepositoryService.sendTyping(this.room.id)
}
}
async editMessage(message: MessageViewModal) {
@@ -570,7 +590,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
cssClass: 'edit-message',
componentProps: {
message: message.message,
roomId: this.roomId,
roomId: this.room.$id,
}
});
@@ -584,7 +604,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
message: res.data.message,
messageId: message.id,
requestId: '',
roomId: this.roomId
roomId: this.room.id
})
}
@@ -607,7 +627,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
ngOnInit() {
this.scrollToBottom();
this.getChatMembers();
this.deleteRecording();
}
@@ -628,14 +647,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
});
}
load = () => {
this.getChatMembers();
}
doRefresh(ev: any) {
this.load();
ev.target.complete();
// ev.target.complete();
}
scrollToBottom = () => {
@@ -747,13 +762,15 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
async sendAudio(fileName) {
const roomId = this.roomId
//Converting base64 to blob
const encodedData = this.audioRecordedDataUrl;
createMessage() {
const message = new MessageViewModal();
message.roomId = this.roomId
if(this.room.id) {
message.roomId = this.room.id
} else {
message.roomId = this.room.$id
}
message.sentAt = new Date().toISOString()
@@ -764,6 +781,40 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
wxUserId: SessionStore.user.UserId
}
message.sentAt = new Date().toISOString()
if(this.room.receiverId) {
message.receiverId = this.room.receiverId
}
return message
}
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;
// console.log('enter')
// await this.chatServiceService.roomSetLocalToFalseById({
// $roomId: this.room.$id,
// roomId: message.value.roomId
// })
this.room.id = message.value.roomId
this.subscribeToChanges()
}
}
async sendAudio(fileName) {
const roomId = this.room.$id
//Converting base64 to blob
const encodedData = this.audioRecordedDataUrl;
const message = this.createMessage();
message.attachments = [{
file: encodedData.split(',')[1],
fileName: "audio",
@@ -773,18 +824,17 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
safeFile: this.sanitiser.bypassSecurityTrustResourceUrl(this.audioRecordedDataUrl)
}]
message.sentAt = new Date().toISOString()
const date = whatsappDate(message.sentAt, false)
if(!this.date[date]) {
this.date[date] = true
const Ballon = XBallon(message)
this.messages1[this.roomId].push(Ballon)
this.messages1[this.room.$id].push(Ballon)
}
this.messages1[this.roomId].push(message)
this.chatServiceService.sendMessage(message, this.roomType)
this.messages1[this.room.$id].push(message)
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
this.messageResult(sendMessage)
setTimeout(() => {
this.scrollToBottomClicked()
@@ -800,45 +850,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.audioRecordedDataUrl = ''
}
showDateDuration(start: any) {
return this.timeService.showDateDuration(start);
}
async goToEvent(event: any) {
let classs;
if (window.innerWidth < 701) {
classs = 'modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
component: ViewEventPage,
componentProps: {
eventId: event.id,
CalendarId: event.calendarId
},
cssClass: classs,
});
modal.onDidDismiss().then((res) => {
});
await modal.present();
}
async sendMessage() {
const message = new MessageViewModal();
const message = this.createMessage();
message.message = this.textField
message.roomId = this.roomId
message.sender = {
userPhoto: '',
wxeMail: SessionStore.user.Email,
wxFullName: SessionStore.user.FullName,
wxUserId: SessionStore.user.UserId
}
message.sentAt = new Date().toISOString()
this.textField = ''
@@ -846,14 +861,15 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
if(!this.date[date]) {
this.date[date] = true
const Ballon = XBallon(message)
this.messages1[this.roomId].push(Ballon)
this.messages1[this.room.$id].push(Ballon)
}
this.messages1[this.roomId].push(message)
this.messages1[this.room.$id].push(message)
setTimeout(() => {
this.scrollToBottomClicked()
}, 100)
const data = await this.chatServiceService.sendMessage(message, this.roomType)
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
this.messageResult(sendMessage)
}
@@ -911,9 +927,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
await modal.present();
}
getChatMembers() {}
async addContacts() {
const modal = await this.modalController.create({
component: ContactsPage,
@@ -956,9 +969,9 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
component: ChatPopoverPage,
cssClass: 'model search-submodal chat-option-aside',
componentProps: {
roomId: this.roomId,
roomId: this.room.id,
members: [],
isAdmin: this.isAdmin,
isAdmin: true,
roomType: this.roomType
}
});
@@ -969,7 +982,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
// this.getRoomInfo();
this.closeAllDesktopComponents.emit();
this.showEmptyContainer.emit();
// this.ChatSystemService.hidingRoom(this.roomId).catch((error) => console.error(error));
// this.ChatSystemService.hidingRoom(this.room.$id).catch((error) => console.error(error));
}
else if (res.data == 'delete') {
this.closeAllDesktopComponents.emit();
@@ -981,7 +994,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
else if (res.data == 'edit') {
//this.closeAllDesktopComponents.emit();
this.openEditGroupPage.emit(this.roomId);
this.openEditGroupPage.emit(this.room.$id);
} else if (res.data == 'addUser') {
this.openGroupContactsPage();
@@ -992,7 +1005,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
openGroupContactsPage() {
this.openGroupContacts.emit(this.roomId);
this.openGroupContacts.emit(this.room.$id);
}
async takePictureMobile() {
@@ -1016,19 +1029,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
if(compressedImage.isOk()) {
const message = new MessageViewModal();
message.roomId = this.roomId
const message = this.createMessage();
message.oneShot = oneShot
message.sender = {
userPhoto: '',
wxeMail: SessionStore.user.Email,
wxFullName: SessionStore.user.FullName,
wxUserId: SessionStore.user.UserId
}
message.sentAt = new Date().toISOString()
message.attachments = [{
file: compressedImage.value.split(',')[1],
fileName: "foto",
@@ -1042,13 +1046,14 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
if(!this.date[date]) {
this.date[date] = true
const Ballon = XBallon(message)
this.messages1[this.roomId].push(Ballon)
this.messages1[this.room.$id].push(Ballon)
}
setTimeout(() => {
this.scrollToBottomClicked()
}, 100)
this.chatServiceService.sendMessage(message, this.roomType)
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
this.messageResult(sendMessage)
}
@@ -1082,18 +1087,9 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
// "title": res.data.selected.Assunto,
// "description": res.data.selected.DocTypeDesc,
const message = new MessageViewModal();
const message = this.createMessage();
message.message = this.textField
message.roomId = this.roomId
message.sentAt = new Date().toISOString()
message.sender = {
userPhoto: '',
wxeMail: SessionStore.user.Email,
wxFullName: SessionStore.user.FullName,
wxUserId: SessionStore.user.UserId
}
message.attachments = [{
fileName: res.data.selected.Assunto,
source: MessageAttachmentSource.Webtrix,
@@ -1107,14 +1103,15 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
if(!this.date[date]) {
this.date[date] = true
const Ballon = XBallon(message)
this.messages1[this.roomId].push(Ballon)
this.messages1[this.room.$id].push(Ballon)
}
this.messages1[this.roomId].push(message)
this.messages1[this.room.$id].push(message)
setTimeout(() => {
this.scrollToBottomClicked()
}, 100)
this.chatServiceService.sendMessage(message, this.roomType)
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
this.messageResult(sendMessage)
this.textField = ''
}
@@ -1178,19 +1175,9 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
if(compressedImage.isOk()) {
const message = new MessageViewModal();
message.roomId = this.roomId
message.sentAt = new Date().toISOString()
const message = this.createMessage();
message.oneShot = oneShot
message.sender = {
userPhoto: '',
wxeMail: SessionStore.user.Email,
wxFullName: SessionStore.user.FullName,
wxUserId: SessionStore.user.UserId
}
message.attachments = [{
file: file.value.base64String,
fileName: "foto",
@@ -1204,14 +1191,15 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
if(!this.date[date]) {
this.date[date] = true
const Ballon = XBallon(message)
this.messages1[this.roomId].push(Ballon)
this.messages1[this.room.$id].push(Ballon)
}
this.messages1[this.roomId].push(message)
this.messages1[this.room.$id].push(message)
setTimeout(() => {
this.scrollToBottomClicked()
}, 100)
this.chatServiceService.sendMessage(message, this.roomType)
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
this.messageResult(sendMessage)
}
}
@@ -1224,7 +1212,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
// this.messageRepositoryService.sendMessageDelete()
this.chatServiceService.messageDelete({
messageId: message.id,
roomId: this.roomId,
roomId: this.room.id,
})
}
@@ -1243,17 +1231,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
if(fileBase64.isOk()) {
const message = new MessageViewModal();
message.roomId = this.roomId
message.sentAt = new Date().toISOString()
message.sender = {
userPhoto: '',
wxeMail: SessionStore.user.Email,
wxFullName: SessionStore.user.FullName,
wxUserId: SessionStore.user.UserId
}
const message = this.createMessage();
message.attachments = [{
file: fileBase64.value.split(',')[1],
@@ -1268,14 +1246,15 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
if(!this.date[date]) {
this.date[date] = true
const Ballon = XBallon(message)
this.messages1[this.roomId].push(Ballon)
this.messages1[this.room.$id].push(Ballon)
}
this.messages1[this.roomId].push(message)
this.messages1[this.room.$id].push(message)
setTimeout(() => {
this.scrollToBottomClicked()
}, 100)
this.chatServiceService.sendMessage(message, this.roomType)
let sendMessage = this.chatServiceService.sendMessage(message, this.roomType)
this.messageResult(sendMessage)
}
} else {
@@ -1286,7 +1265,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
async _openChatOptions() {
const roomId = this.roomId;
const roomId = this.room.$id;
const enterAnimation = (baseEl: any) => {
@@ -1318,7 +1297,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
component: ChatOptionsFeaturesPage,
cssClass: 'model profile-modal search-submodal',
componentProps: {
roomId: this.roomId,
roomId: this.room.$id,
members: [],
}
});
@@ -1330,7 +1309,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
if (res['data'] == 'meeting') {
//this.closeAllDesktopComponents.emit();
let data = {
roomId: this.roomId,
roomId: this.room.$id,
members: []
}
this.openNewEventPage.emit(data);
@@ -27,6 +27,6 @@
<button *ngIf="isAdmin && roomType == EnumRoomType.Group" (click)="setRoomOwner()" class="btn-cancel" shape="round">Adicionar admin</button>
<div class="solid"></div>
<button (click)="close('cancel')" full class="btn-cancel mobile-only" shape="round">Cancelar</button>
<button *ngIf="isAdmin && roomType == EnumRoomType.Group" (click)="deleteGroup()" class="btn-delete" shape="round">Apagar grupo</button>
<button (click)="deleteGroup()" class="btn-delete" shape="round">Apagar grupo</button>
</div>
</ion-content>
@@ -1,24 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { ViewOncesPage } from './view-onces.page';
describe('ViewOncesPage', () => {
let component: ViewOncesPage;
let fixture: ComponentFixture<ViewOncesPage>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ ViewOncesPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(ViewOncesPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
View File
+1
View File
@@ -35,6 +35,7 @@ export class MessageViewModal {
$id?: string
id?: string
roomId?: string
$roomId: string
receiverId?: number
message?: string
canEdit: boolean = false
+4 -1
View File
@@ -4,7 +4,8 @@ import { isDocument } from "src/app/utils/document-mimetype";
export class RoomViewModel implements IRoom {
id: typeof RoomEntitySchema._input.id
$id: typeof RoomEntitySchema._input.$id
id?: typeof RoomEntitySchema._input.id
roomName: typeof RoomEntitySchema._input.roomName
createdBy: typeof RoomEntitySchema._input.createdBy
createdAt: typeof RoomEntitySchema._input.createdAt
@@ -12,6 +13,8 @@ export class RoomViewModel implements IRoom {
roomType: typeof RoomEntitySchema._input.roomType
members: typeof RoomEntitySchema._input.members
messages: typeof RoomEntitySchema._input.messages
local: typeof RoomEntitySchema._input.local
receiverId?: typeof RoomEntitySchema._input.receiverId
displayDate = ''
lastMessageImage = false
lastMessageDocument = false