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