feat: recipient details
Signed-off-by: Sebastian <krupinski01@gmail.com>
This commit is contained in:
@@ -10,14 +10,16 @@ import Placeholder from '@tiptap/extension-placeholder'
|
||||
import { EntityObject } from '@MailManager/models/entity'
|
||||
import type { CollectionObject } from '@MailManager/models'
|
||||
import { useMailStore } from '@/stores/mailStore'
|
||||
import type { MessageAddressInterface } from '@MailManager/types/message'
|
||||
import { ComposerMode } from '@/types/composer'
|
||||
import ComposerToolbar from '@/components/composer/ComposerToolbar.vue'
|
||||
import ComposerRecipients from '@/components/composer/ComposerRecipients.vue'
|
||||
import ComposerEditor from '@/components/composer/ComposerEditor.vue'
|
||||
|
||||
// Props
|
||||
interface Props {
|
||||
mode: 'new' | 'reply' | 'forward'
|
||||
source?: EntityObject | null
|
||||
mode: ComposerMode
|
||||
source?: EntityObject | MessageAddressInterface | null
|
||||
folder?: CollectionObject | null
|
||||
}
|
||||
|
||||
@@ -83,7 +85,15 @@ function initializeComposerFromProps() {
|
||||
mailStore.resetComposerState()
|
||||
resetComposerFields()
|
||||
|
||||
if (!props.source) {
|
||||
if (props.mode === ComposerMode.Fresh) {
|
||||
if (props.source && 'address' in props.source) {
|
||||
// If source is an email address, pre-fill the "To" field
|
||||
to.value = [props.source.address]
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (props.source instanceof EntityObject == false) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -94,19 +104,19 @@ function initializeComposerFromProps() {
|
||||
const sentAt = sourceMessage.sent || props.source.created || ''
|
||||
const sentLabel = sentAt ? new Date(sentAt).toLocaleString() : 'an unknown time'
|
||||
|
||||
if (props.mode === 'reply') {
|
||||
if (props.mode === ComposerMode.Reply) {
|
||||
const fromEmail = sourceMessage.replyTo?.[0]?.address || sourceMessage.from?.address
|
||||
to.value = fromEmail ? [fromEmail] : []
|
||||
subject.value = /^Re:/i.test(originalSubject)
|
||||
? originalSubject
|
||||
: `Re: ${originalSubject}`
|
||||
editor.value?.commands.setContent(
|
||||
`<p><br></p><p>On ${sentLabel}, ${senderName} wrote:</p><blockquote>${originalBody}</blockquote>`,
|
||||
`<p><br></p><p>---------- Original message ---------</p><p>From: ${senderName}</p><p>Date: ${sentLabel}</p><p>Subject: ${originalSubject}</p><blockquote>${originalBody}</blockquote>`,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (props.mode === 'forward') {
|
||||
if (props.mode === ComposerMode.Forward) {
|
||||
subject.value = /^Fwd:/i.test(originalSubject)
|
||||
? originalSubject
|
||||
: `Fwd: ${originalSubject}`
|
||||
|
||||
Reference in New Issue
Block a user