fix donwload attachment and modal to edit message

This commit is contained in:
Peter Maquiran
2024-08-29 12:13:15 +01:00
parent 97ad62e2b6
commit d8d294b662
38 changed files with 627 additions and 198 deletions
@@ -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)