mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
35 lines
914 B
TypeScript
35 lines
914 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import { MessageLocalDataSourceService } from '../../../data/data-source/message/message-local-data-source.service';
|
|
import { MessageOutPutDataDTO } from '../../../data/dto/message/messageOutputDTO';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class SocketMessageUpdateUseCaseService {
|
|
|
|
constructor(
|
|
private messageLocalDataSourceService: MessageLocalDataSourceService
|
|
) { }
|
|
|
|
|
|
async execute(data: MessageOutPutDataDTO) {
|
|
const result = await this.messageLocalDataSourceService.messageExist({id: data.id})
|
|
|
|
const incomingMessage = {
|
|
...data,
|
|
sending: false,
|
|
roomId:data.chatRoomId
|
|
}
|
|
|
|
// delete data.chatRoomId
|
|
|
|
if(result.isOk()) {
|
|
console.log('message exist')
|
|
return this.messageLocalDataSourceService.update({...result.value, ...incomingMessage})
|
|
} else {
|
|
console.log('message else')
|
|
}
|
|
|
|
}
|
|
}
|