Merge pull request #2707 from ahstro/refactor/use-id-normalization
Use id normalization where applicable
This commit is contained in:
Коммит
e5a6a40acc
|
@ -18,7 +18,8 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {normalizeFolderId} from './normalization'
|
||||
|
||||
export const UNIFIED_ACCOUNT_ID = 0
|
||||
export const UNIFIED_INBOX_ID = btoa('inbox')
|
||||
export const UNIFIED_INBOX_UID = UNIFIED_ACCOUNT_ID + '-' + UNIFIED_INBOX_ID
|
||||
export const UNIFIED_INBOX_UID = normalizeFolderId(UNIFIED_ACCOUNT_ID, UNIFIED_INBOX_ID)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
import {defaultTo, head} from 'ramda'
|
||||
|
||||
import {UNIFIED_ACCOUNT_ID} from './constants'
|
||||
import {normalizeEnvelopeListId} from './normalization'
|
||||
import {normalizeEnvelopeListId, normalizeFolderId, normalizeMessageId} from './normalization'
|
||||
|
||||
export const getters = {
|
||||
getPreference: state => (key, def) => {
|
||||
|
@ -35,7 +35,7 @@ export const getters = {
|
|||
return state.accountList.map(id => state.accounts[id])
|
||||
},
|
||||
getFolder: state => (accountId, folderId) => {
|
||||
return state.folders[accountId + '-' + folderId]
|
||||
return state.folders[normalizeFolderId(accountId, folderId)]
|
||||
},
|
||||
getFolders: state => accountId => {
|
||||
return state.accounts[accountId].folders.map(folderId => state.folders[folderId])
|
||||
|
@ -53,7 +53,7 @@ export const getters = {
|
|||
)
|
||||
},
|
||||
getEnvelope: state => (accountId, folderId, id) => {
|
||||
return state.envelopes[accountId + '-' + folderId + '-' + id]
|
||||
return state.envelopes[normalizeMessageId(accountId, folderId, id)]
|
||||
},
|
||||
getEnvelopeById: state => id => {
|
||||
return state.envelopes[id]
|
||||
|
@ -63,6 +63,6 @@ export const getters = {
|
|||
return list.map(msgId => state.envelopes[msgId])
|
||||
},
|
||||
getMessage: state => (accountId, folderId, id) => {
|
||||
return state.messages[accountId + '-' + folderId + '-' + id]
|
||||
return state.messages[normalizeMessageId(accountId, folderId, id)]
|
||||
},
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import {sortMailboxes} from '../imap/MailboxSorter'
|
|||
import {UNIFIED_ACCOUNT_ID} from './constants'
|
||||
|
||||
const addFolderToState = (state, account) => folder => {
|
||||
const id = account.id + '-' + folder.id
|
||||
const id = normalizedFolderId(account.id, folder.id)
|
||||
folder.accountId = account.id
|
||||
folder.envelopeLists = {}
|
||||
Vue.set(state.folders, id, folder)
|
||||
|
@ -151,7 +151,7 @@ export default {
|
|||
Vue.delete(list, normalizedMessageId(accountId, folderId, id))
|
||||
},
|
||||
addMessage(state, {accountId, folderId, message}) {
|
||||
const uid = accountId + '-' + folderId + '-' + message.id
|
||||
const uid = normalizedMessageId(accountId, folderId, message.id)
|
||||
message.accountId = accountId
|
||||
message.folderId = folderId
|
||||
message.uid = uid
|
||||
|
@ -160,7 +160,7 @@ export default {
|
|||
updateDraft(state, {draft, data, newUid}) {
|
||||
// Update draft's UID
|
||||
const oldUid = draft.uid
|
||||
const uid = draft.accountId + '-' + draft.folderId + '-' + newUid
|
||||
const uid = normalizedMessageId(draft.accountId, draft.folderId, newUid)
|
||||
console.debug('saving draft as UID ' + uid)
|
||||
draft.uid = uid
|
||||
|
||||
|
@ -169,7 +169,7 @@ export default {
|
|||
draft.subject = data.subject
|
||||
|
||||
// Update ref in folder's envelope list
|
||||
const envs = state.folders[draft.accountId + '-' + draft.folderId].envelopes
|
||||
const envs = state.folders[normalizedFolderId(draft.accountId, draft.folderId)].envelopes
|
||||
const idx = envs.indexOf(oldUid)
|
||||
if (idx < 0) {
|
||||
console.warn('not replacing draft ' + oldUid + ' in envelope list because it did not exist')
|
||||
|
@ -184,6 +184,6 @@ export default {
|
|||
Vue.set(state.messages, uid, draft)
|
||||
},
|
||||
removeMessage(state, {accountId, folderId, id}) {
|
||||
Vue.delete(state.messages, accountId + '-' + folderId + '-' + id)
|
||||
Vue.delete(state.messages, normalizedMessageId(accountId, folderId, id))
|
||||
},
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче