diff --git a/src/components/MailboxThread.vue b/src/components/MailboxThread.vue index bf75ab543a..95aaa40025 100644 --- a/src/components/MailboxThread.vue +++ b/src/components/MailboxThread.vue @@ -220,7 +220,7 @@ import { priorityImportantQuery, priorityOtherQuery, } from '../util/priorityInbox.js' -import { detect, html } from '../util/text.js' +import { detect, toHtml, toPlain } from '../util/text.js' const START_MAILBOX_DEBOUNCE = 5 * 1000 @@ -535,6 +535,9 @@ export default { if (this.$route.params.accountId !== 0 && this.$route.params.accountId !== '0') { accountId = parseInt(this.$route.params.accountId, 10) } + + const body = detect(this.$route.query.body ?? '') + this.mainStore.startComposerSession({ data: { accountId, @@ -542,7 +545,9 @@ export default { cc: this.stringToRecipients(this.$route.query.cc), bcc: this.stringToRecipients(this.$route.query.bcc), subject: this.$route.query.subject || '', - body: this.$route.query.body ? detect(this.$route.query.body) : html(''), + isHtml: body.format === 'html', + bodyHtml: toHtml(body).value, + bodyPlain: toPlain(body).value, }, }) } diff --git a/src/store/mainStore/actions.js b/src/store/mainStore/actions.js index 27388e9b9c..83059563be 100644 --- a/src/store/mainStore/actions.js +++ b/src/store/mainStore/actions.js @@ -115,6 +115,15 @@ import { } from '../constants.js' import useOutboxStore from '../outboxStore.js' +/** + * @todo Type definition for ComposerSessionData is incomplete + * + * @typedef {object} ComposerSessionData + * @property {boolean} isHtml whether this is a html message + * @property {string} bodyHtml the body as html + * @property {string} bodyPlain the body as plain text + */ + const sliceToPage = slice(0, PAGE_SIZE) const findIndividualMailboxes = curry((getMailboxes, specialRole) => pipe( @@ -1936,7 +1945,7 @@ export default function mainStoreActions() { * * @param {object} payload Data for the new message * @param payload.type - * @param payload.data + * @param {ComposerSessionData} payload.data * @param payload.forwardedMessages * @param payload.originalSendAt * @param payload.smartReply diff --git a/src/util/text.js b/src/util/text.js index 8e4a692537..4c6a02a97c 100644 --- a/src/util/text.js +++ b/src/util/text.js @@ -51,6 +51,10 @@ export const plain = wrap('plain') */ export const html = wrap('html') +/** + * @param {string} str + * @return {Text} + */ export function detect(str) { if (!isString(str)) { // Fall back to a hopefully sane default