111
111
@discard-draft =" discardDraft"
112
112
@upload-attachment =" onAttachmentUploading"
113
113
@send =" onSend"
114
- @show-toolbar =" handleShow"
115
- @new-mailbox-then-send =" onNewSentMailbox" />
114
+ @show-toolbar =" handleShow"
115
+ @new-mailbox-then-send =" onNewSentMailbox" />
116
116
</div >
117
117
118
118
<div v-if =" showRecipientPane" class =" right-pane" >
@@ -133,7 +133,6 @@ import { translate as t } from '@nextcloud/l10n'
133
133
134
134
import logger from ' ../logger.js'
135
135
import { toPlain , toHtml , plain } from ' ../util/text.js'
136
- import { getMailboxExists } from ' ../service/MailboxService'
137
136
import Composer from ' ./Composer.vue'
138
137
import { UNDO_DELAY } from ' ../store/constants.js'
139
138
import { matchError } from ' ../errors/match.js'
@@ -299,28 +298,26 @@ export default {
299
298
toHtml,
300
299
plain,
301
300
async onNewSentMailbox (data ) {
302
- const account = this .$store . getters .getAccount (data .accountId )
301
+ const account = this .mainStore .getAccount (data .accountId )
303
302
showWarning (t (' mail' , ' Setting Sent default folder' ))
304
303
this .creatingSentMailbox = true
305
- const mailboxes = this .$store . getters .getMailboxes (data .accountId )
304
+ const mailboxes = this .mainStore .getMailboxes (data .accountId )
306
305
const sentMailboxId = mailboxes .find ((mailbox ) => mailbox .name === account .personalNamespace + ' Sent' || mailbox .name === account .personalNamespace + t (' mail' , ' Sent' ))? .databaseId
307
306
if (sentMailboxId) {
308
307
await this .setSentMailboxAndResend (account, sentMailboxId, data)
309
308
return
310
309
}
311
- logger .info (' creating automated_sent mailbox' )
312
- await this .$store
313
- .dispatch (' createMailbox' , { account, name: account .personalNamespace + t (' mail' , ' Sent' ) })
314
- .then ((e ) => {
315
- logger .info (` mailbox ${ account .personalNamespace + t (' mail' , ' Sent' )} created` )
316
- this .newSentMailboxId = e .databaseId
317
- })
318
- .catch ((error ) => {
319
- this .creatingSentMailbox = false
320
- showError (t (' mail' , ' Could not create new mailbox, please try setting a sent mailbox manually' ))
321
- logger .error (' could not create mailbox' , { error })
322
- this .$emit (' close' )
323
- })
310
+ logger .info (` creating ${ t (' mail' , ' Sent' )} mailbox` )
311
+ try {
312
+ const newSentMailbox = await this .mainStore .createMailbox ({ account, name: account .personalNamespace + t (' mail' , ' Sent' ) })
313
+ logger .info (` mailbox ${ account .personalNamespace + t (' mail' , ' Sent' )} created` )
314
+ this .newSentMailboxId = newSentMailbox .databaseId
315
+ } catch (error) {
316
+ this .creatingSentMailbox = false
317
+ showError (t (' mail' , ' Could not create new mailbox, please try setting a sent mailbox manually' ))
318
+ logger .error (' could not create mailbox' , { error })
319
+ this .$emit (' close' )
320
+ }
324
321
325
322
if (this .newSentMailboxId ) {
326
323
await this .setSentMailboxAndResend (account, this .newSentMailboxId , data)
@@ -333,24 +330,24 @@ export default {
333
330
334
331
async setSentMailboxAndResend (account , id , data ) {
335
332
logger .debug (' setting sent mailbox to ' + id)
336
- await this .$store .dispatch (' patchAccount' , {
337
- account,
338
- data: {
339
- sentMailboxId: id,
340
- },
341
- }).then (() => {
333
+ try {
334
+ await this .mainStore .patchAccount ({
335
+ account,
336
+ data: {
337
+ sentMailboxId: id,
338
+ },
339
+ })
342
340
logger .debug (' Resending message after new setting sent mailbox' )
343
341
this .onSend (data)
344
342
showSuccess (t (' mail' , ' Sent folder set, resending message' ))
345
- })
346
- .catch ((error ) => {
347
- showError (t (' mail' , ' Couldn\' t set sent default folder, please try manually before sending a new message' ))
348
- logger .error (' could not set sent mailbox' , { error })
349
- this .$emit (' close' )
350
- })
351
- .finally (() => {
352
- this .creatingSentMailbox = false
353
- })
343
+ } catch (error) {
344
+ showError (t (' mail' , ' Couldn\' t set sent default folder, please try manually before sending a new message' ))
345
+ logger .error (' could not set sent mailbox' , { error })
346
+ this .$emit (' close' )
347
+ } finally {
348
+ this .creatingSentMailbox = false
349
+ }
350
+
354
351
},
355
352
/**
356
353
* @param data Message data
0 commit comments