mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
fix donwload attachment and modal to edit message
This commit is contained in:
+15
-2
@@ -3,6 +3,17 @@ import { MessageAttachmentByMessageIdInput } from './message-attachment-by-messa
|
||||
import { AttachmentRemoteDataSourceService } from 'src/app/module/chat/data/repository/attachment/attachment-remote-repository.service'
|
||||
import { AttachmentLocalDataSource } from 'src/app/module/chat/data/repository/attachment/attachment-local-repository.service'
|
||||
import { err, Result } from 'neverthrow';
|
||||
import { AttachmentTableSchema } from 'src/app/infra/database/dexie/instance/chat/schema/attachment';
|
||||
import { z } from 'zod';
|
||||
import { createBlobUrl } from 'src/app/utils/ToBase64';
|
||||
|
||||
const GetMessageAttachmentLocallyByMessageIdSchema = AttachmentTableSchema.pick({
|
||||
$messageId: true
|
||||
})
|
||||
|
||||
export type GetMessageAttachmentLocallyByMessageId = z.infer<typeof GetMessageAttachmentLocallyByMessageIdSchema>
|
||||
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -15,7 +26,7 @@ export class GetMessageAttachmentLocallyUseCaseService {
|
||||
) { }
|
||||
|
||||
|
||||
async execute(input: MessageAttachmentByMessageIdInput): Promise<Result<string, any>> {
|
||||
async execute(input: GetMessageAttachmentLocallyByMessageId): Promise<Result<string, any>> {
|
||||
|
||||
const getLocalAttachment = await this.AttachmentLocalDataSource.findOne({
|
||||
$messageId: input.$messageId
|
||||
@@ -23,7 +34,9 @@ export class GetMessageAttachmentLocallyUseCaseService {
|
||||
|
||||
if(getLocalAttachment.isOk()) {
|
||||
if(getLocalAttachment.value) {
|
||||
return getLocalAttachment.map(e => e.file)
|
||||
const dataUrl = await createBlobUrl(getLocalAttachment.value.file)
|
||||
|
||||
return dataUrl
|
||||
}
|
||||
} else {
|
||||
return err(getLocalAttachment.error)
|
||||
|
||||
Reference in New Issue
Block a user