Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/store
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2022-04-06 15:30:04 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2022-04-06 16:01:20 +0300
commit50524c2ea20abc0cb55f4a07f6206eb692b933ee (patch)
tree7998a7e2f3f268eaaea0b757a9707ac81e287c98 /src/store
parent76f9733800d6a117f83a20e64eb8e444c857ab90 (diff)
Pipe all composer data through the Vuex store
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'src/store')
-rw-r--r--src/store/actions.js36
-rw-r--r--src/store/getters.js5
-rw-r--r--src/store/mutations.js5
3 files changed, 42 insertions, 4 deletions
diff --git a/src/store/actions.js b/src/store/actions.js
index e18243545..8c5180d1f 100644
--- a/src/store/actions.js
+++ b/src/store/actions.js
@@ -82,6 +82,11 @@ import { updateAccount as updateSieveAccount } from '../service/SieveService'
import { PAGE_SIZE, UNIFIED_INBOX_ID } from './constants'
import * as ThreadService from '../service/ThreadService'
import { getPrioritySearchQueries } from '../util/priorityInbox'
+import { html, plain } from '../util/text'
+import Axios from '@nextcloud/axios'
+import { generateUrl } from '@nextcloud/router'
+import { showWarning } from '@nextcloud/dialogs'
+import { translate as t } from '@nextcloud/l10n'
const sliceToPage = slice(0, PAGE_SIZE)
@@ -253,8 +258,37 @@ export default {
updated,
})
},
- async showMessageComposer({ commit }, { forwardedMessages = [], templateMessageId = undefined }) {
+ async showMessageComposer({ commit, dispatch }, { type = 'imap', data = {}, forwardedMessages = [], templateMessageId }) {
+ if (templateMessageId) {
+ const message = await dispatch('fetchMessage', templateMessageId)
+ // Merge the original into any existing data
+ data = {
+ ...data,
+ message,
+ }
+
+ // Fetch and transform the body into a rich text object
+ if (message.hasHtmlBody) {
+ const resp = await Axios.get(
+ generateUrl('/apps/mail/api/messages/{id}/html?plain=true', {
+ id: templateMessageId,
+ })
+ )
+
+ data.body = html(resp.data)
+ } else {
+ data.body = plain(message.body)
+ }
+
+ // TODO: implement attachments
+ if (message.attachments.length) {
+ showWarning(t('mail', 'Attachments were not copied. Please add them manually.'))
+ }
+ }
+
commit('showMessageComposer', {
+ type,
+ data,
forwardedMessages,
templateMessageId,
})
diff --git a/src/store/getters.js b/src/store/getters.js
index 5c87d45c7..255c65fa1 100644
--- a/src/store/getters.js
+++ b/src/store/getters.js
@@ -57,7 +57,10 @@ export const getters = {
showMessageComposer: (state) => {
return state.newMessage !== undefined
},
- messageComposerOptions: (state) => {
+ composerMessage: (state) => {
+ return state.newMessage
+ },
+ composerMessageOptions: (state) => {
return state.newMessage?.options
},
getEnvelope: (state) => (id) => {
diff --git a/src/store/mutations.js b/src/store/mutations.js
index ff9c8efc0..9bb71337e 100644
--- a/src/store/mutations.js
+++ b/src/store/mutations.js
@@ -174,11 +174,12 @@ export default {
}
removeRec(account)
},
- showMessageComposer(state, { forwardedMessages, templateMessageId }) {
+ showMessageComposer(state, { type, data, forwardedMessages }) {
Vue.set(state, 'newMessage', {
+ type,
+ data,
options: {
forwardedMessages,
- templateMessageId,
},
})
},