feat: implement attachment preview
Signed-off-by: Sebastian <krupinski01@gmail.com>
This commit is contained in:
@@ -61,7 +61,7 @@ const handleAttachmentClick = (attachment: MessagePartInterface, index: number):
|
||||
|
||||
const handleViewerRetrieve = (item: AttachmentItem): Promise<Blob> => {
|
||||
if (!props.entity) return Promise.reject(new Error('No message selected'))
|
||||
return mailUiStore.attachmentBlob(props.entity, item.meta.attachment)
|
||||
return mailUiStore.attachmentPreviewBlob(props.entity, item.meta.attachment)
|
||||
}
|
||||
|
||||
// Format date for display
|
||||
|
||||
@@ -640,6 +640,20 @@ export const useMailOperationsStore = defineStore('mailOperationsStore', () => {
|
||||
return blob
|
||||
}
|
||||
|
||||
async function attachmentPreviewBlob(entity: EntityObject, part: MessagePartInterface): Promise<Blob> {
|
||||
return entitiesStore.preview({
|
||||
target: entity.identifier,
|
||||
part: {
|
||||
blobId: part.blobId ?? undefined,
|
||||
partId: part.partId ?? undefined,
|
||||
cid: part.cid ?? undefined,
|
||||
type: part.type || 'application/octet-stream',
|
||||
size: part.size ?? null,
|
||||
},
|
||||
variant: 'popover',
|
||||
})
|
||||
}
|
||||
|
||||
// ── Exports ───────────────────────────────────────────────────────────────
|
||||
|
||||
return {
|
||||
@@ -681,6 +695,7 @@ export const useMailOperationsStore = defineStore('mailOperationsStore', () => {
|
||||
moveMessages,
|
||||
downloadMessage,
|
||||
attachmentBlob,
|
||||
attachmentPreviewBlob,
|
||||
moveFolder,
|
||||
renameFolder,
|
||||
isServiceFolderLoading,
|
||||
|
||||
@@ -714,6 +714,10 @@ export const useMailUiStore = defineStore('mailUiStore', () => {
|
||||
return mailOperationsStore.attachmentBlob(entity, part)
|
||||
}
|
||||
|
||||
function attachmentPreviewBlob(entity: EntityObject, part: Parameters<typeof mailOperationsStore.attachmentPreviewBlob>[1]) {
|
||||
return mailOperationsStore.attachmentPreviewBlob(entity, part)
|
||||
}
|
||||
|
||||
return {
|
||||
sidebarVisible,
|
||||
settingsDialogVisible,
|
||||
@@ -763,6 +767,7 @@ export const useMailUiStore = defineStore('mailUiStore', () => {
|
||||
moveMessages,
|
||||
downloadMessage,
|
||||
attachmentBlob,
|
||||
attachmentPreviewBlob,
|
||||
messageSelectionModeActivate,
|
||||
messageSelectionModeDeactivate,
|
||||
messageSelectionToggleOne,
|
||||
@@ -788,4 +793,4 @@ export const useMailUiStore = defineStore('mailUiStore', () => {
|
||||
confirmDeleteFolder,
|
||||
flagSelectedMessages,
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user