Skip to content

Commit

Permalink
fixup! fix: add ability to send alternet text (html and plain)
Browse files Browse the repository at this point in the history
  • Loading branch information
st3iny committed Dec 17, 2024
1 parent 6e546c7 commit 04cec39
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
9 changes: 7 additions & 2 deletions src/components/NewMessageModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,10 @@ export default {
return this.draftsPromise
},
getDataForServer(data) {
return {
const dataForServer = {
...data,
id: data.id,
accountId: data.accountId,
body: data.isHtml ? data.body.value : toPlain(data.body).value,
editorBody: data.body.value,
to: data.to,
cc: data.cc,
Expand All @@ -331,6 +330,12 @@ export default {
sendAt: data.sendAt,
draftId: this.composerData?.draftId,
}
if (data.isHtml) {
dataForServer.bodyHtml = data.body.value
} else {
dataForServer.bodyPlain = toPlain(data.body).value
}
return dataForServer
},
onAttachmentUploading(done, data) {
this.attachmentsPromise = this.attachmentsPromise
Expand Down
8 changes: 7 additions & 1 deletion src/components/OutboxMessageListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,17 @@ export default {
if (this.message.editorBody === null) {
return
}
const bodyData = {}
if (this.message.isHtml) {
bodyData.bodyHtml = html(this.message.body)
} else {
bodyData.bodyPlain = plain(this.message.body)
}
await this.$store.dispatch('startComposerSession', {
type: 'outbox',
data: {
...this.message,
body: this.message.isHtml ? html(this.message.body) : plain(this.message.body),
...bodyData,
},
})
},
Expand Down
14 changes: 10 additions & 4 deletions src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,11 @@ export default {
let originalSendAt
if (type === 'outbox' && data.id && data.sendAt) {
originalSendAt = data.sendAt
const message = {
...data,
body: data.isHtml ? data.body.value : toPlain(data.body).value,
const message = { ...data }
if (data.isHtml) {
message.bodyHtml = data.body.value
} else {
message.bodyPlain = toPlain(data.body).value
}
const outboxStore = useOutboxStore()
await outboxStore.stopMessage({ message })
Expand All @@ -503,7 +505,11 @@ export default {
const message = getters.composerMessage
if (restoreOriginalSendAt && message.type === 'outbox' && message.options?.originalSendAt) {
const body = message.data.body
message.body = message.data.isHtml ? body.value : toPlain(body).value
if (message.data.isHtml) {
message.bodyHtml = body.value
} else {
message.bodyPlain = toPlain(body).value
}
message.sendAt = message.options.originalSendAt
updateDraft(message)
}
Expand Down
10 changes: 8 additions & 2 deletions src/store/outboxStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,18 @@ export default defineStore('outbox', {
logger.info('Attempting to stop sending message ' + message.id)
const stopped = await this.stopMessage({ message })
logger.info('Message ' + message.id + ' stopped', { message: stopped })
// The composer expects rich body data and not just a string
const bodyData = {}
if (message.isHtml) {
bodyData.bodyHtml = html(message.body)
} else {
bodyData.bodyPlain = plain(message.body)
}
await store.dispatch('startComposerSession', {
type: 'outbox',
data: {
...message,
// The composer expects rich body data and not just a string
body: message.isHtml ? html(message.body) : plain(message.body),
...bodyData,
},
}, { root: true })
}, {
Expand Down

0 comments on commit 04cec39

Please sign in to comment.