Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mailbox being renamed after every update #6252

Merged
merged 1 commit into from
Apr 21, 2022
Merged
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
16 changes: 11 additions & 5 deletions src/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ import { sortMailboxes } from '../imap/MailboxSorter'
import { normalizedEnvelopeListId } from './normalization'
import { UNIFIED_ACCOUNT_ID } from './constants'

const addMailboxToState = curry((state, account, mailbox) => {
mailbox.accountId = account.id
mailbox.mailboxes = []
Vue.set(mailbox, 'envelopeLists', {})

const transformMailboxName = (account, mailbox) => {
// Add all mailboxes (including submailboxes to state, but only toplevel to account
const nameWithoutPrefix = account.personalNamespace
? mailbox.name.replace(new RegExp(escapeRegExp(account.personalNamespace)), '')
Expand All @@ -58,6 +54,14 @@ const addMailboxToState = curry((state, account, mailbox) => {
mailbox.displayName = nameWithoutPrefix
mailbox.path = ''
}
}

const addMailboxToState = curry((state, account, mailbox) => {
mailbox.accountId = account.id
mailbox.mailboxes = []
Vue.set(mailbox, 'envelopeLists', {})

transformMailboxName(account, mailbox)

Vue.set(state.mailboxes, mailbox.databaseId, mailbox)
const parent = Object.values(state.mailboxes)
Expand Down Expand Up @@ -155,6 +159,8 @@ export default {
addMailboxToState(state, account, mailbox)
},
updateMailbox(state, { mailbox }) {
const account = state.accounts[mailbox.accountId]
transformMailboxName(account, mailbox)
Vue.set(state.mailboxes, mailbox.databaseId, mailbox)
},
removeMailbox(state, { id }) {
Expand Down