send messag on reconnect

This commit is contained in:
Peter Maquiran
2024-08-07 15:36:15 +01:00
parent bbacc35b08
commit d55450ccbb
3 changed files with 21 additions and 9 deletions
@@ -12,6 +12,7 @@ import { messageListDetermineChanges } from '../async/list/rooms/messageListChan
import { MessageEntity } from '../../domain/entity/message';
import { InstanceId } from '../../domain/chat-service.service';
import { MessageMapper } from '../../domain/mapper/messageMapper';
import { MessageOutPutDataDTO } from '../dto/message/messageOutputDTO';
@Injectable({
@@ -26,6 +27,15 @@ export class MessageRepositoryService {
private messageLocalDataSourceService: MessageLocalDataSourceService
) {}
async createMessageLocally(entity: MessageEntity) {
const requestId = InstanceId +'@'+ uuidv4();
const roomId = entity.roomId
return await this.messageLocalDataSourceService.sendMessage(entity)
}
async sendMessage(entity: MessageEntity) {
const requestId = InstanceId +'@'+ uuidv4();
@@ -35,7 +45,7 @@ export class MessageRepositoryService {
if(localActionResult.isOk()) {
const DTO = MessageMapper.fromDomain(entity, requestId)
const sendMessageResult = await this.messageLiveSignalRDataSourceService.sendMessage(DTO)
const sendMessageResult = await this.messageLiveSignalRDataSourceService.sendMessage<MessageOutPutDataDTO>(DTO)
if(sendMessageResult.isOk()) {
@@ -51,11 +61,9 @@ export class MessageRepositoryService {
}
return this.messageLocalDataSourceService.update({...clone, sending: false, roomId: entity.roomId})
return ok(true)
} else {
console.log('no message to upload', sendMessageResult.error)
return this.messageLocalDataSourceService.update({sending: false, $id: localActionResult.value})
return err(false)
await this.messageLocalDataSourceService.update({sending: false, $id: localActionResult.value})
return err('no connection')
}
} else {