mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix message
This commit is contained in:
@@ -72,10 +72,16 @@
|
||||
</div>
|
||||
|
||||
<div *ngIf="attachment.fileType == MessageAttachmentFileType.Image">
|
||||
<img
|
||||
*ngIf="message.oneShot != true && attachment.blobURl != true"
|
||||
[src]="attachment.safeFile"
|
||||
(load)="onImageLoad(message, messageIndex)"
|
||||
(error)="onImageError()"
|
||||
>
|
||||
|
||||
<img
|
||||
*ngIf="message.oneShot != true"
|
||||
[src]="attachment.safeFile"
|
||||
*ngIf="message.oneShot != true && attachment.blobURl"
|
||||
[src]="attachment.safeFile|safehtml"
|
||||
(load)="onImageLoad(message, messageIndex)"
|
||||
(error)="onImageError()"
|
||||
>
|
||||
|
||||
@@ -320,10 +320,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
// }
|
||||
// return true; // Keep messages without an id
|
||||
// });
|
||||
|
||||
|
||||
messages = messages.sort((a: any, b: any) => a.$createAt - b.$createAt)
|
||||
|
||||
console.time("mappingTime");
|
||||
for(const message of messages) {
|
||||
const date = whatsappDate(message.sentAt, false)
|
||||
if(!this.date[date]) {
|
||||
@@ -334,12 +331,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
allMessage.push(new MessageViewModal(message))
|
||||
}
|
||||
console.timeEnd("mappingTime");
|
||||
|
||||
console.time("mappingTime");
|
||||
|
||||
this.messages1[this.roomId] = allMessage
|
||||
|
||||
console.timeEnd("mappingTime");
|
||||
|
||||
|
||||
// if(messages.length >= 1) {
|
||||
// this.messages1[this.roomId].push(LastMessage)
|
||||
@@ -370,13 +367,15 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
for(const message of this.messages1[this.roomId]) {
|
||||
if(message.hasAttachment && message.attachments[0].source != MessageAttachmentSource.Webtrix) {
|
||||
|
||||
if(message.$id) {
|
||||
this.chatServiceService.getMessageAttachmentByMessageId(message).then((result)=> {
|
||||
if(result.isOk()) {
|
||||
message.attachments[0].safeFile = result.value
|
||||
this.chatServiceService.getMessageAttachmentByMessageId(message).then((result)=> {
|
||||
if(result.isOk()) {
|
||||
message.attachments[0].safeFile = result.value
|
||||
|
||||
if(result.value.startsWith('blob:http')) {
|
||||
message.attachments[0].blobURl = true
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
@@ -437,26 +436,34 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
listenToIncomingMessage() {
|
||||
this.messageReceiveSubject?.unsubscribe();
|
||||
this.messageReceiveSubject = this.chatServiceService.listenToIncomingMessage(this.roomId).subscribe(async (message) => {
|
||||
this.messageReceiveSubject = this.chatServiceService.listenToIncomingMessage(this.roomId).subscribe(async (_message) => {
|
||||
|
||||
const date = whatsappDate(message.sentAt, false)
|
||||
const date = whatsappDate(_message.sentAt, false)
|
||||
if(!this.date[date]) {
|
||||
this.date[date] = true
|
||||
const Ballon = XBallon(message)
|
||||
const Ballon = XBallon(_message)
|
||||
this.messages1[this.roomId].push(Ballon)
|
||||
}
|
||||
|
||||
const message = new MessageViewModal(_message)
|
||||
this.messages1[this.roomId].push(new MessageViewModal(message))
|
||||
|
||||
console.log('message=======', message)
|
||||
|
||||
if(message.hasAttachment) {
|
||||
|
||||
const result = await this.chatServiceService.downloadMessageAttachmentByMessageId({
|
||||
$messageId: message.$id,
|
||||
$messageId: message.id,
|
||||
id: message.attachments[0].id
|
||||
})
|
||||
|
||||
if(result.isOk()){
|
||||
if(result.isOk()) {
|
||||
message.attachments[0].safeFile = result.value
|
||||
if((result.value as unknown as string).startsWith('blob:http')) {
|
||||
message.attachments[0].blobURl = true
|
||||
} else {
|
||||
message.attachments[0].blobURl = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,15 @@ import { IonicModule } from '@ionic/angular';
|
||||
import { ViewOncesPageRoutingModule } from './view-onces-routing.module';
|
||||
|
||||
import { ViewOncesImagePage } from './view-onces.page';
|
||||
import { PipesModule } from 'src/app/pipes/pipes.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
IonicModule,
|
||||
ViewOncesPageRoutingModule
|
||||
ViewOncesPageRoutingModule,
|
||||
PipesModule
|
||||
],
|
||||
declarations: [ViewOncesImagePage]
|
||||
})
|
||||
|
||||
@@ -11,6 +11,14 @@
|
||||
|
||||
<ion-content>
|
||||
<div class="justify-center align-center d-flex width-100 height-100">
|
||||
<img [src]="params.imageDataUrl">
|
||||
|
||||
<img
|
||||
*ngIf="blobURl"
|
||||
[src]="params.imageDataUrl|safehtml"
|
||||
>
|
||||
<img
|
||||
*ngIf="!blobURl"
|
||||
[src]="params.imageDataUrl"
|
||||
>
|
||||
</div>
|
||||
</ion-content>
|
||||
|
||||
@@ -19,19 +19,22 @@ export type ViewOncesImagePageInput = z.infer<typeof ViewOncesImagePageInputSche
|
||||
export class ViewOncesImagePage implements OnInit {
|
||||
|
||||
params: ViewOncesImagePageInput
|
||||
|
||||
blobURl: Boolean;
|
||||
|
||||
constructor(
|
||||
private navParams: NavParams,
|
||||
public modalController: ModalController,
|
||||
) {
|
||||
) {
|
||||
this.params = this.navParams.data
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
// console.log('niceddd')
|
||||
// this.message = this.navParams.get('message');
|
||||
// console.log('this.message', this.message)
|
||||
if(this.params.imageDataUrl.startsWith('blob:http')) {
|
||||
this.blobURl = true
|
||||
} else {
|
||||
this.blobURl = false
|
||||
}
|
||||
}
|
||||
|
||||
closePage() {
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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)
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import { IMessageType } from "src/app/core/chat/entity/message";
|
||||
|
||||
export function XBallon(message: any) {
|
||||
const MessageBallon = new MessageViewModal(message as any)
|
||||
MessageBallon.$id = 0
|
||||
MessageBallon.$id = ''
|
||||
MessageBallon.id = ''
|
||||
MessageBallon.isDeleted = false
|
||||
MessageBallon.sentAt = message.sentAt
|
||||
|
||||
Reference in New Issue
Block a user