fix message

This commit is contained in:
Peter Maquiran
2024-09-05 11:45:54 +01:00
parent 106267aee9
commit b0e1dd74cd
16 changed files with 237 additions and 78 deletions
+35 -7
View File
@@ -1,10 +1,38 @@
import { MessageEntity, MessageEntitySchema, IMessageType, IMessage } from "src/app/core/chat/entity/message";
import { MessageEntity, MessageEntitySchema, IMessageType, IMessage, MessageEntityAttachmentSchema } from "src/app/core/chat/entity/message";
import { SessionStore } from "src/app/store/session.service";
import { z } from "zod";
const MessageViewModalSchema = MessageEntitySchema.pick({
$id: true,
canEdit: true,
editedAt: true,
id: true,
info: true,
isDeleted: true,
message: true,
messageType: true,
oneShot: true,
origin: true,
reactions: true,
receiverId: true,
requestId: true,
requireUnlock: true,
roomId: true,
sendAttemp: true,
sender: true,
sending: true,
sentAt: true
}).extend({
attachments: MessageEntityAttachmentSchema.extend({
blobURl: z.boolean()
}).array().optional()
})
export type i = z.infer<typeof MessageViewModalSchema>
export class MessageViewModal {
$id?: number
$id?: string
id?: string
roomId?: string
receiverId?: number
@@ -13,15 +41,15 @@ export class MessageViewModal {
oneShot: boolean = false
sentAt?: string
requireUnlock: boolean = false
info: typeof MessageEntitySchema._type.info = []
sender!: typeof MessageEntitySchema._type.sender
info: typeof MessageViewModalSchema._type.info = []
sender!: typeof MessageViewModalSchema._type.sender
sending: boolean = false
sendAttemp = 0
messageType = IMessageType.normal
attachments: typeof MessageEntitySchema._type.attachments = []
reactions: typeof MessageEntitySchema._type.reactions = []
attachments: typeof MessageViewModalSchema._type.attachments = []
reactions: typeof MessageViewModalSchema._type.reactions = []
requestId: string
isDeleted: typeof MessageEntitySchema._type.isDeleted = false
isDeleted: typeof MessageViewModalSchema._type.isDeleted = false
status!: 'allViewed' | 'allReceived'| 'enviado'| 'enviar'
messageUiType!: 'info-meeting'| 'my-message'| 'other-message'
+53
View File
@@ -0,0 +1,53 @@
import { Injectable } from '@angular/core';
import { MessageViewModal } from './model/message';
import { MessageLocalDataSourceService } from 'src/app/module/chat/data/repository/message/message-local-data-source.service';
import { whatsappDate } from '../../shared/utils/whatappdate';
import { XBallon } from '../utils/messageBallon';
@Injectable({
providedIn: 'root'
})
export class RoomStore {
roomId: string;
date: {[key: string]: Object} = {}
constructor(
private messageLocalDataSourceService: MessageLocalDataSourceService,
) {}
openRoom() {
}
messages1: {[key: string]: MessageViewModal[]} = {}
async getMessages() {
// dont remove this line
this.messages1[this.roomId] = []
let messages = await this.messageLocalDataSourceService.getItems(this.roomId)
this.messages1[this.roomId] = []
this.date = {}
const allMessage = [];
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)
}
allMessage.push(new MessageViewModal(message))
}
console.timeEnd("mappingTime");
this.messages1[this.roomId] = allMessage
// if(messages.length >= 1) {
// this.messages1[this.roomId].push(LastMessage)
// }
}
}