Skip to content

Commit 3913ba7

Browse files
committed
fixup! fix no sent mailbox configured
Signed-off-by: hamza221 <[email protected]>
1 parent 48edd0e commit 3913ba7

File tree

3 files changed

+32
-35
lines changed

3 files changed

+32
-35
lines changed

src/components/AccountDefaultsSettings.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default {
104104
await this.mainStore.patchAccount({
105105
account: this.account,
106106
data: {
107-
sentMailboxId,
107+
sentMailboxId: null,
108108
},
109109
})
110110
} catch (error) {

src/components/Composer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ export default {
12761276
this.saveDraftDebounced()
12771277
},
12781278
async onSend(_, force = false) {
1279-
const selectedAccount = this.$store.getters.getAccount(this.selectedAlias.id)
1279+
const selectedAccount = this.mainStore.getAccount(this.selectedAlias.id)
12801280
if (!selectedAccount?.sentMailboxId) {
12811281
this.$emit('new-mailbox-then-send', {
12821282
...this.getMessageData(),

src/components/NewMessageModal.vue

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@
111111
@discard-draft="discardDraft"
112112
@upload-attachment="onAttachmentUploading"
113113
@send="onSend"
114-
@show-toolbar="handleShow"
115-
@new-mailbox-then-send="onNewSentMailbox"/>
114+
@show-toolbar="handleShow"
115+
@new-mailbox-then-send="onNewSentMailbox" />
116116
</div>
117117

118118
<div v-if="showRecipientPane" class="right-pane">
@@ -133,7 +133,6 @@ import { translate as t } from '@nextcloud/l10n'
133133
134134
import logger from '../logger.js'
135135
import { toPlain, toHtml, plain } from '../util/text.js'
136-
import { getMailboxExists } from '../service/MailboxService'
137136
import Composer from './Composer.vue'
138137
import { UNDO_DELAY } from '../store/constants.js'
139138
import { matchError } from '../errors/match.js'
@@ -299,28 +298,26 @@ export default {
299298
toHtml,
300299
plain,
301300
async onNewSentMailbox(data) {
302-
const account = this.$store.getters.getAccount(data.accountId)
301+
const account = this.mainStore.getAccount(data.accountId)
303302
showWarning(t('mail', 'Setting Sent default folder'))
304303
this.creatingSentMailbox = true
305-
const mailboxes = this.$store.getters.getMailboxes(data.accountId)
304+
const mailboxes = this.mainStore.getMailboxes(data.accountId)
306305
const sentMailboxId = mailboxes.find((mailbox) => mailbox.name === account.personalNamespace + 'Sent' || mailbox.name === account.personalNamespace + t('mail', 'Sent'))?.databaseId
307306
if (sentMailboxId) {
308307
await this.setSentMailboxAndResend(account, sentMailboxId, data)
309308
return
310309
}
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+
}
324321
325322
if (this.newSentMailboxId) {
326323
await this.setSentMailboxAndResend(account, this.newSentMailboxId, data)
@@ -333,24 +330,24 @@ export default {
333330
334331
async setSentMailboxAndResend(account, id, data) {
335332
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+
})
342340
logger.debug('Resending message after new setting sent mailbox')
343341
this.onSend(data)
344342
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+
354351
},
355352
/**
356353
* @param data Message data

0 commit comments

Comments
 (0)