mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 13:55:51 +00:00
fix ballon
This commit is contained in:
@@ -101,6 +101,10 @@ export class DexieRepository<T, R> implements IDexieRepository<T, R> {
|
|||||||
const updatedCount = await this.table.update(id, dataValidation.data);
|
const updatedCount = await this.table.update(id, dataValidation.data);
|
||||||
return ok(updatedCount);
|
return ok(updatedCount);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Logger.error(`dexie.js failed to update into ${this.table.name}, invalid data`, {
|
||||||
|
data: updatedDocument,
|
||||||
|
id,
|
||||||
|
});
|
||||||
return err(new Error('Failed to update document: ' + error.message));
|
return err(new Error('Failed to update document: ' + error.message));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ export function messageListDetermineChanges(serverList: MessageTable[], localLis
|
|||||||
// Identify changed items
|
// Identify changed items
|
||||||
const changedItems = serverList.filter(item => {
|
const changedItems = serverList.filter(item => {
|
||||||
const localItem = localDict[item.id];
|
const localItem = localDict[item.id];
|
||||||
|
|
||||||
|
if(localItem?.$id) {
|
||||||
|
item.$id = localItem.$id
|
||||||
|
}
|
||||||
|
|
||||||
return localItem && (item.editedAt !== localItem.editedAt || item.reactions.some((r, index) => {
|
return localItem && (item.editedAt !== localItem.editedAt || item.reactions.some((r, index) => {
|
||||||
const localReaction = localItem.reactions[index];
|
const localReaction = localItem.reactions[index];
|
||||||
return !localReaction || r.reactedAt !== localReaction.reactedAt;
|
return !localReaction || r.reactedAt !== localReaction.reactedAt;
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ export class MessageAttachmentByMessageIdUseCase {
|
|||||||
private AttachmentLocalDataSource: AttachmentLocalDataSource
|
private AttachmentLocalDataSource: AttachmentLocalDataSource
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
@XTracerAsync({name:'Message-Attachment-By-MessageIdUseCase', module:'chat', bugPrint: true, waitNThrow: 15000})
|
@XTracerAsync({name:'Message-Attachment-By-MessageIdUseCase', module:'chat', bugPrint: true, waitNThrow: 5000})
|
||||||
async execute(input: MessageAttachmentByMessageIdInput, tracing?: TracingType): Promise<Result<string, any>> {
|
async execute(input: MessageAttachmentByMessageIdInput, tracing?: TracingType): Promise<Result<string, any>> {
|
||||||
|
|
||||||
tracing.setAttribute('messageId', input.id)
|
tracing.setAttribute('messageId', input.id)
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ export class MessageDeleteLiveUseCaseService {
|
|||||||
public repository: MessageSocketRepositoryService
|
public repository: MessageSocketRepositoryService
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
@XTracerAsync({name:'MessageDeleteLiveUseCaseService', module:'chat', bugPrint: true})
|
@XTracerAsync({name:'MessageDeleteLiveUseCaseService', module:'chat', bugPrint: true, waitNThrow: 2000})
|
||||||
async execute(data: MessageDeleteInputDTO, tracing?: TracingType) {
|
async execute(data: MessageDeleteInputDTO, tracing?: TracingType) {
|
||||||
tracing.log('MessageDeleteLiveUseCaseService payload', {
|
tracing.log('MessageDeleteLiveUseCaseService payload', {
|
||||||
data: data
|
data: data
|
||||||
|
|||||||
@@ -49,21 +49,22 @@ export class SyncAllRoomMessagesService {
|
|||||||
const { addedItems, changedItems, deletedItems } = messageListDetermineChanges(result.value.data, localResult);
|
const { addedItems, changedItems, deletedItems } = messageListDetermineChanges(result.value.data, localResult);
|
||||||
|
|
||||||
for (const message of changedItems) {
|
for (const message of changedItems) {
|
||||||
|
delete message.sentAt
|
||||||
let clone: MessageTable = { ...message, roomId: room.id };
|
let clone: MessageTable = { ...message, roomId: room.id };
|
||||||
await this.messageLocalDataSourceService.update(clone.$id, clone);
|
await this.messageLocalDataSourceService.update(clone.$id, clone);
|
||||||
|
|
||||||
const me = message.info.find(e => e.memberId === SessionStore.user.UserId && typeof e.deliverAt === 'string');
|
// const me = message.info.find(e => e.memberId === SessionStore.user.UserId && typeof e.deliverAt === 'string');
|
||||||
|
|
||||||
if (!me) {
|
// if (!me) {
|
||||||
this.MessageSocketRepositoryService.sendDeliverAt({
|
// this.MessageSocketRepositoryService.sendDeliverAt({
|
||||||
memberId: SessionStore.user.UserId,
|
// memberId: SessionStore.user.UserId,
|
||||||
messageId: message.id,
|
// messageId: message.id,
|
||||||
roomId: message.roomId,
|
// roomId: message.roomId,
|
||||||
requestId: uuidv4()
|
// requestId: uuidv4()
|
||||||
});
|
// });
|
||||||
|
|
||||||
tracing.addEvent('send deliver roomId ' + room.id);
|
// tracing.addEvent('send deliver roomId ' + room.id);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const message of addedItems) {
|
for (const message of addedItems) {
|
||||||
|
|||||||
@@ -69,8 +69,6 @@ export class RoomBoldSyncUseCaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.log(message.info.filter(e => typeof e.readAt == 'string' && e.memberId == SessionStore.user.UserId).length == 1, '', message)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
+36
-11
@@ -31,13 +31,26 @@ export type ISocketMessageCreateOutput = z.infer<typeof SocketMessageCreateOutpu
|
|||||||
})
|
})
|
||||||
export class SocketMessageCreateUseCaseService {
|
export class SocketMessageCreateUseCaseService {
|
||||||
|
|
||||||
|
private broadcastChannel: BroadcastChannel;
|
||||||
|
private processedMessages = new Set<string>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private messageLocalDataSourceService: MessageLocalDataSourceService,
|
private messageLocalDataSourceService: MessageLocalDataSourceService,
|
||||||
) { }
|
) {
|
||||||
|
this.broadcastChannel = new BroadcastChannel('socket-message');
|
||||||
|
this.broadcastChannel.onmessage = (event) => {
|
||||||
|
console.log('hello', event.data)
|
||||||
|
const messageId = event.data;
|
||||||
|
this.processedMessages.add(messageId);
|
||||||
|
};
|
||||||
|
|
||||||
|
// this.broadcastChannel.postMessage('incomingMessage.id');
|
||||||
|
}
|
||||||
|
|
||||||
@XTracerAsync({name:'Socket-Message-Create-UseCase', module:'chat', bugPrint: true})
|
@XTracerAsync({name:'Socket-Message-Create-UseCase', module:'chat', bugPrint: true})
|
||||||
async execute(input: ISocketMessageCreateOutput, tracing?: TracingType) {
|
async execute(input: ISocketMessageCreateOutput, tracing?: TracingType) {
|
||||||
|
|
||||||
|
this.broadcastChannel.postMessage(input.id);
|
||||||
ParamsValidation(SocketMessageCreateOutputSchema, input, tracing)
|
ParamsValidation(SocketMessageCreateOutputSchema, input, tracing)
|
||||||
|
|
||||||
const incomingMessage = {
|
const incomingMessage = {
|
||||||
@@ -45,19 +58,31 @@ export class SocketMessageCreateUseCaseService {
|
|||||||
sending: false
|
sending: false
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('create message', {incomingMessage});
|
// Check if the message ID already exists in the processedMessages set
|
||||||
|
if (this.processedMessages.has(incomingMessage.id)) {
|
||||||
tracing?.addEvent("Message Create start")
|
console.warn(`Duplicate message detected: ${incomingMessage.id}`);
|
||||||
const result = await this.messageLocalDataSourceService.insert(incomingMessage)
|
return; // Exit early to prevent duplicate handling
|
||||||
tracing?.addEvent("Message Create end")
|
|
||||||
|
|
||||||
if(result.isOk()) {
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
tracing?.addEvent("error while creating message")
|
console.log('no duplicate')
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the message ID to the processedMessages set and broadcast it
|
||||||
|
this.processedMessages.add(incomingMessage.id);
|
||||||
|
|
||||||
|
|
||||||
|
console.log('create message', { incomingMessage });
|
||||||
|
|
||||||
|
tracing?.addEvent("Message Create start");
|
||||||
|
const result = await this.messageLocalDataSourceService.insert(incomingMessage);
|
||||||
|
tracing?.addEvent("Message Create end");
|
||||||
|
|
||||||
|
if (result.isOk()) {
|
||||||
|
// Optionally, you can handle post-insertion logic here
|
||||||
|
} else {
|
||||||
|
tracing?.addEvent("error while creating message");
|
||||||
tracing.log("error while creating message", {
|
tracing.log("error while creating message", {
|
||||||
error: result.error
|
error: result.error
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,9 +48,9 @@
|
|||||||
*ngFor="let message of messages1[roomId]; let messageIndex = index" class="messages-list-item-wrapper px-10-em"
|
*ngFor="let message of messages1[roomId]; let messageIndex = index" class="messages-list-item-wrapper px-10-em"
|
||||||
[ngClass]="{
|
[ngClass]="{
|
||||||
'info-meeting': message.messageType == IMessageType.information && !message.ballon,
|
'info-meeting': message.messageType == IMessageType.information && !message.ballon,
|
||||||
'info-ballon': message.ballon,
|
'info-ballon': message.ballon == true,
|
||||||
'my-message': message.messageType == IMessageType.normal && message?.sender?.wxUserId === SessionStore.user.UserId,
|
'my-message': message.messageType == IMessageType.normal && message?.sender?.wxUserId === SessionStore.user.UserId && !message.ballon,
|
||||||
'other-message': message.messageType == IMessageType.normal && message?.sender?.wxUserId !== SessionStore.user.UserId
|
'other-message': message.messageType == IMessageType.normal && message?.sender?.wxUserId !== SessionStore.user.UserId && !message.ballon
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<div class="message-container rotate-div" *ngIf="message.showMessage">
|
<div class="message-container rotate-div" *ngIf="message.showMessage">
|
||||||
@@ -148,7 +148,7 @@
|
|||||||
<div class="message-container rotate-div" *ngIf="message.isDeleted == true">
|
<div class="message-container rotate-div" *ngIf="message.isDeleted == true">
|
||||||
Mensagem foi eliminada
|
Mensagem foi eliminada
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="message.messageType == IMessageType.information" class="text-center">
|
<div *ngIf="message.messageType == IMessageType.information && !message.ballon" class="text-center">
|
||||||
{{ message.message }}
|
{{ message.message }}
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="message.ballon" class="text-center ballon">
|
<div *ngIf="message.ballon" class="text-center ballon">
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
async loadAttachment() {
|
async loadAttachment() {
|
||||||
for(const message of this.messages1[this.roomId]) {
|
for(const message of this.messages1[this.roomId]) {
|
||||||
if(message.hasAttachment) {
|
if(message.hasAttachment && message.attachments[0].source != MessageAttachmentSource.Webtrix) {
|
||||||
|
|
||||||
if(message.$id) {
|
if(message.$id) {
|
||||||
this.chatServiceService.getMessageAttachmentByMessageId(message).then((result)=> {
|
this.chatServiceService.getMessageAttachmentByMessageId(message).then((result)=> {
|
||||||
@@ -422,6 +422,13 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
this.messageReceiveSubject?.unsubscribe();
|
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)
|
||||||
|
if(!this.date[date]) {
|
||||||
|
this.date[date] = true
|
||||||
|
const Ballon = XBallon(message)
|
||||||
|
this.messages1[this.roomId].push(Ballon)
|
||||||
|
}
|
||||||
|
|
||||||
this.messages1[this.roomId].push(new MessageViewModal(message))
|
this.messages1[this.roomId].push(new MessageViewModal(message))
|
||||||
|
|
||||||
if(message.hasAttachment) {
|
if(message.hasAttachment) {
|
||||||
@@ -754,8 +761,19 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
safeFile: this.sanitiser.bypassSecurityTrustResourceUrl(this.audioRecordedDataUrl)
|
safeFile: this.sanitiser.bypassSecurityTrustResourceUrl(this.audioRecordedDataUrl)
|
||||||
}]
|
}]
|
||||||
|
|
||||||
this.chatServiceService.sendMessage(message, this.roomType)
|
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.roomId].push(message)
|
this.messages1[this.roomId].push(message)
|
||||||
|
this.chatServiceService.sendMessage(message, this.roomType)
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.scrollToBottomClicked()
|
this.scrollToBottomClicked()
|
||||||
}, 100)
|
}, 100)
|
||||||
@@ -811,6 +829,14 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
message.sentAt = new Date().toISOString()
|
message.sentAt = new Date().toISOString()
|
||||||
|
|
||||||
this.textField = ''
|
this.textField = ''
|
||||||
|
|
||||||
|
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.roomId].push(message)
|
this.messages1[this.roomId].push(message)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.scrollToBottomClicked()
|
this.scrollToBottomClicked()
|
||||||
@@ -997,7 +1023,14 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
mimeType: 'image/'+picture.value.format
|
mimeType: 'image/'+picture.value.format
|
||||||
}]
|
}]
|
||||||
|
|
||||||
this.messages1[this.roomId].push(new MessageViewModal(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)
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.scrollToBottomClicked()
|
this.scrollToBottomClicked()
|
||||||
}, 100)
|
}, 100)
|
||||||
@@ -1053,6 +1086,13 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
docId: res.data.selected.Id,
|
docId: res.data.selected.Id,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
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.roomId].push(new MessageViewModal(message))
|
this.messages1[this.roomId].push(new MessageViewModal(message))
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.scrollToBottomClicked()
|
this.scrollToBottomClicked()
|
||||||
@@ -1143,6 +1183,13 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
description: ''
|
description: ''
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
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.roomId].push(message)
|
this.messages1[this.roomId].push(message)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.scrollToBottomClicked()
|
this.scrollToBottomClicked()
|
||||||
@@ -1199,6 +1246,13 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
mimeType: file.value.type
|
mimeType: file.value.type
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
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.roomId].push(message)
|
this.messages1[this.roomId].push(message)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.scrollToBottomClicked()
|
this.scrollToBottomClicked()
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export class MessageViewModal {
|
|||||||
messageUiType!: 'info-meeting'| 'my-message'| 'other-message'
|
messageUiType!: 'info-meeting'| 'my-message'| 'other-message'
|
||||||
showReaction = false
|
showReaction = false
|
||||||
showMessage = false
|
showMessage = false
|
||||||
ballo = false
|
ballon = false
|
||||||
|
|
||||||
constructor(model?: IMessage) {
|
constructor(model?: IMessage) {
|
||||||
if(model) {
|
if(model) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { SessionStore } from "src/app/store/session.service";
|
import { SessionStore } from "src/app/store/session.service";
|
||||||
import { MessageViewModal } from "../store/model/message";
|
import { MessageViewModal } from "../store/model/message";
|
||||||
import { whatsappDate } from "../../shared/utils/whatappdate";
|
import { whatsappDate } from "../../shared/utils/whatappdate";
|
||||||
|
import { IMessageType } from "src/app/core/chat/entity/message";
|
||||||
|
|
||||||
export function XBallon(message: any) {
|
export function XBallon(message: any) {
|
||||||
const MessageBallon = new MessageViewModal(message as any)
|
const MessageBallon = new MessageViewModal(message as any)
|
||||||
@@ -9,7 +10,8 @@ export function XBallon(message: any) {
|
|||||||
MessageBallon.isDeleted = false
|
MessageBallon.isDeleted = false
|
||||||
MessageBallon.sentAt = message.sentAt
|
MessageBallon.sentAt = message.sentAt
|
||||||
MessageBallon.message = whatsappDate(message.sentAt, false)
|
MessageBallon.message = whatsappDate(message.sentAt, false)
|
||||||
MessageBallon.ballo = true
|
MessageBallon.messageType == IMessageType.information
|
||||||
|
MessageBallon.ballon = true
|
||||||
MessageBallon.sender = {
|
MessageBallon.sender = {
|
||||||
userPhoto: '',
|
userPhoto: '',
|
||||||
wxeMail: SessionStore.user.Email,
|
wxeMail: SessionStore.user.Email,
|
||||||
|
|||||||
Reference in New Issue
Block a user