Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/components/MailboxThread.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -535,14 +535,19 @@ 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,
to: this.stringToRecipients(this.$route.query.to),
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,
},
})
}
Expand Down
11 changes: 10 additions & 1 deletion src/store/mainStore/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/util/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading