feat: message and attachment download
Signed-off-by: Sebastian <krupinski01@gmail.com>
This commit is contained in:
@@ -633,6 +633,33 @@ export const useMailStore = defineStore('mailStore', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadMessage(entity: EntityObject, index?: number) {
|
||||
const target = entity.identifier
|
||||
let part = null
|
||||
|
||||
if (index !== undefined) {
|
||||
part = entity.properties.attachments?.[Number(index)] ?? null
|
||||
}
|
||||
|
||||
try {
|
||||
await entitiesStore.download(target, part)
|
||||
} catch (error) {
|
||||
const messageText = error instanceof Error
|
||||
? error.message
|
||||
: index === undefined
|
||||
? 'Failed to download message'
|
||||
: 'Failed to download attachment'
|
||||
console.error(
|
||||
index === undefined
|
||||
? '[Mail][Operations] Failed to download message:'
|
||||
: '[Mail][Operations] Failed to download attachment:',
|
||||
error,
|
||||
)
|
||||
notify(messageText, 'error')
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
function notify(message: string, color: 'success' | 'error' | 'info' | 'warning' = 'success') {
|
||||
showSnackbar({ message, color })
|
||||
}
|
||||
@@ -672,6 +699,7 @@ export const useMailStore = defineStore('mailStore', () => {
|
||||
deleteMessages,
|
||||
deleteFolder,
|
||||
moveMessages,
|
||||
downloadMessage,
|
||||
moveFolder,
|
||||
renameFolder,
|
||||
notify,
|
||||
|
||||
Reference in New Issue
Block a user